Interface MessagingService
-
public interface MessagingService
Interface for low level messaging primitives.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description void
registerHandler(java.lang.String type, java.util.function.BiConsumer<Endpoint,byte[]> handler, java.util.concurrent.Executor executor)
Registers a new message handler for message type.void
registerHandler(java.lang.String type, java.util.function.BiFunction<Endpoint,byte[],byte[]> handler, java.util.concurrent.Executor executor)
Registers a new message handler for message type.void
registerHandler(java.lang.String type, java.util.function.BiFunction<Endpoint,byte[],java.util.concurrent.CompletableFuture<byte[]>> handler)
Registers a new message handler for message type.default java.util.concurrent.CompletableFuture<byte[]>
sendAndReceive(Endpoint ep, java.lang.String type, byte[] payload)
Sends a message asynchronously and expects a response.default java.util.concurrent.CompletableFuture<byte[]>
sendAndReceive(Endpoint ep, java.lang.String type, byte[] payload, java.time.Duration timeout)
Sends a message asynchronously and expects a response.java.util.concurrent.CompletableFuture<byte[]>
sendAndReceive(Endpoint ep, java.lang.String type, byte[] payload, java.time.Duration timeout, java.util.concurrent.Executor executor)
Sends a message synchronously and expects a response.default java.util.concurrent.CompletableFuture<byte[]>
sendAndReceive(Endpoint ep, java.lang.String type, byte[] payload, java.util.concurrent.Executor executor)
Sends a message synchronously and expects a response.java.util.concurrent.CompletableFuture<java.lang.Void>
sendAsync(Endpoint ep, java.lang.String type, byte[] payload)
Sends a message asynchronously to the specified communication end point.void
unregisterHandler(java.lang.String type)
Unregister current handler, if one exists for message type.
-
-
-
Method Detail
-
sendAsync
java.util.concurrent.CompletableFuture<java.lang.Void> sendAsync(Endpoint ep, java.lang.String type, byte[] payload)
Sends a message asynchronously to the specified communication end point. The message is specified using the type and payload.- Parameters:
ep
- end point to send the message to.type
- type of message.payload
- message payload bytes.- Returns:
- future that is completed when the message is sent
-
sendAndReceive
default java.util.concurrent.CompletableFuture<byte[]> sendAndReceive(Endpoint ep, java.lang.String type, byte[] payload)
Sends a message asynchronously and expects a response.- Parameters:
ep
- end point to send the message to.type
- type of message.payload
- message payload.- Returns:
- a response future
-
sendAndReceive
default java.util.concurrent.CompletableFuture<byte[]> sendAndReceive(Endpoint ep, java.lang.String type, byte[] payload, java.util.concurrent.Executor executor)
Sends a message synchronously and expects a response.- Parameters:
ep
- end point to send the message to.type
- type of message.payload
- message payload.executor
- executor over which any follow up actions after completion will be executed.- Returns:
- a response future
-
sendAndReceive
default java.util.concurrent.CompletableFuture<byte[]> sendAndReceive(Endpoint ep, java.lang.String type, byte[] payload, java.time.Duration timeout)
Sends a message asynchronously and expects a response.- Parameters:
ep
- end point to send the message to.type
- type of message.payload
- message payload.timeout
- operation timeout- Returns:
- a response future
-
sendAndReceive
java.util.concurrent.CompletableFuture<byte[]> sendAndReceive(Endpoint ep, java.lang.String type, byte[] payload, java.time.Duration timeout, java.util.concurrent.Executor executor)
Sends a message synchronously and expects a response.- Parameters:
ep
- end point to send the message to.type
- type of message.payload
- message payload.executor
- executor over which any follow up actions after completion will be executed.timeout
- operation timeout- Returns:
- a response future
-
registerHandler
void registerHandler(java.lang.String type, java.util.function.BiConsumer<Endpoint,byte[]> handler, java.util.concurrent.Executor executor)
Registers a new message handler for message type.- Parameters:
type
- message type.handler
- message handlerexecutor
- executor to use for running message handler logic.
-
registerHandler
void registerHandler(java.lang.String type, java.util.function.BiFunction<Endpoint,byte[],byte[]> handler, java.util.concurrent.Executor executor)
Registers a new message handler for message type.- Parameters:
type
- message type.handler
- message handlerexecutor
- executor to use for running message handler logic.
-
registerHandler
void registerHandler(java.lang.String type, java.util.function.BiFunction<Endpoint,byte[],java.util.concurrent.CompletableFuture<byte[]>> handler)
Registers a new message handler for message type.- Parameters:
type
- message type.handler
- message handler
-
unregisterHandler
void unregisterHandler(java.lang.String type)
Unregister current handler, if one exists for message type.- Parameters:
type
- message type
-
-