Package io.atomix.cluster.messaging
Interface MessagingService
- All Known Subinterfaces:
ManagedMessagingService
- All Known Implementing Classes:
NettyMessagingService
public interface MessagingService
Interface for low level messaging primitives.
-
Method Summary
Modifier and TypeMethodDescriptionaddress()Returns the local messaging service address.Returns the interfaces to which the local messaging service is bind.booleanReturns a boolean value indicating whether the managed object is running.voidregisterHandler(String type, BiConsumer<Address, byte[]> handler, Executor executor) Registers a new message handler for message type.voidregisterHandler(String type, BiFunction<Address, byte[], byte[]> handler, Executor executor) Registers a new message handler for message type.voidregisterHandler(String type, BiFunction<Address, byte[], CompletableFuture<byte[]>> handler) Registers a new message handler for message type.default CompletableFuture<byte[]>sendAndReceive(Address address, String type, byte[] payload) Sends a message asynchronously and expects a response.CompletableFuture<byte[]>sendAndReceive(Address address, String type, byte[] payload, boolean keepAlive) Sends a message asynchronously and expects a response.CompletableFuture<byte[]>sendAndReceive(Address address, String type, byte[] payload, boolean keepAlive, Duration timeout) Sends a message asynchronously and expects a response.CompletableFuture<byte[]>sendAndReceive(Address address, String type, byte[] payload, boolean keepAlive, Duration timeout, Executor executor) Sends a message synchronously and expects a response.CompletableFuture<byte[]>sendAndReceive(Address address, String type, byte[] payload, boolean keepAlive, Executor executor) Sends a message synchronously and expects a response.default CompletableFuture<byte[]>sendAndReceive(Address address, String type, byte[] payload, Duration timeout) Sends a message asynchronously and expects a response.default CompletableFuture<byte[]>sendAndReceive(Address address, String type, byte[] payload, Executor executor) Sends a message synchronously and expects a response.default CompletableFuture<Void>Sends a message asynchronously to the specified communication address.Sends a message asynchronously to the specified communication address.voidunregisterHandler(String type) Unregister current handler, if one exists for message type.
-
Method Details
-
address
Address address()Returns the local messaging service address. This is the address used by other nodes to communicate to this service.- Returns:
- the address remote nodes use to communicate to this node
-
bindingAddresses
Collection<Address> bindingAddresses()Returns the interfaces to which the local messaging service is bind.- Returns:
- the address the messaging service is bound to
-
sendAsync
Sends a message asynchronously to the specified communication address. The message is specified using the type and payload.- Parameters:
address- address to send the message to.type- type of message.payload- message payload bytes.- Returns:
- future that is completed when the message is sent
-
sendAsync
Sends a message asynchronously to the specified communication address. The message is specified using the type and payload.- Parameters:
address- address to send the message to.type- type of message.payload- message payload bytes.keepAlive- whether to keep the connection alive after usage- Returns:
- future that is completed when the message is sent
-
sendAndReceive
Sends a message asynchronously and expects a response.- Parameters:
address- address to send the message to.type- type of message.payload- message payload.- Returns:
- a response future
-
sendAndReceive
CompletableFuture<byte[]> sendAndReceive(Address address, String type, byte[] payload, boolean keepAlive) Sends a message asynchronously and expects a response.- Parameters:
address- address to send the message to.type- type of message.payload- message payload.keepAlive- whether to keep the connection alive after usage- Returns:
- a response future
-
sendAndReceive
default CompletableFuture<byte[]> sendAndReceive(Address address, String type, byte[] payload, Executor executor) Sends a message synchronously and expects a response.- Parameters:
address- address 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
CompletableFuture<byte[]> sendAndReceive(Address address, String type, byte[] payload, boolean keepAlive, Executor executor) Sends a message synchronously and expects a response.- Parameters:
address- address to send the message to.type- type of message.payload- message payload.keepAlive- whether to keep the connection alive after usageexecutor- executor over which any follow up actions after completion will be executed.- Returns:
- a response future
-
sendAndReceive
default CompletableFuture<byte[]> sendAndReceive(Address address, String type, byte[] payload, Duration timeout) Sends a message asynchronously and expects a response.- Parameters:
address- address to send the message to.type- type of message.payload- message payload.timeout- response timeout- Returns:
- a response future
-
sendAndReceive
CompletableFuture<byte[]> sendAndReceive(Address address, String type, byte[] payload, boolean keepAlive, Duration timeout) Sends a message asynchronously and expects a response.- Parameters:
address- address to send the message to.type- type of message.payload- message payload.keepAlive- whether to keep the connection alive after usagetimeout- response timeout- Returns:
- a response future
-
sendAndReceive
CompletableFuture<byte[]> sendAndReceive(Address address, String type, byte[] payload, boolean keepAlive, Duration timeout, Executor executor) Sends a message synchronously and expects a response.- Parameters:
address- address to send the message to.type- type of message.payload- message payload.keepAlive- whether to keep the connection alive after usagetimeout- response timeoutexecutor- executor over which any follow up actions after completion will be executed.- Returns:
- a response future
-
registerHandler
Registers a new message handler for message type.- Parameters:
type- message type.handler- message handlerexecutor- executor to use for running message handler logic.
-
registerHandler
Registers a new message handler for message type.- Parameters:
type- message type.handler- message handlerexecutor- executor to use for running message handler logic.
-
registerHandler
Registers a new message handler for message type.- Parameters:
type- message type.handler- message handler
-
unregisterHandler
Unregister current handler, if one exists for message type.- Parameters:
type- message type
-
isRunning
boolean isRunning()Returns a boolean value indicating whether the managed object is running.- Returns:
- Indicates whether the managed object is running.
-