Package io.atomix.cluster.messaging
Interface MessagingService
- All Known Subinterfaces:
ManagedMessagingService
public interface MessagingService
Interface for low level messaging primitives.
-
Nested Class Summary
Nested Classes Modifier and Type Interface Description static classMessagingService.BuilderMessaging service builder. -
Method Summary
Modifier and Type Method Description io.atomix.utils.net.Addressaddress()Returns the local messaging service address.voidregisterHandler(String type, java.util.function.BiConsumer<io.atomix.utils.net.Address,byte[]> handler, Executor executor)Registers a new message handler for message type.voidregisterHandler(String type, java.util.function.BiFunction<io.atomix.utils.net.Address,byte[],byte[]> handler, Executor executor)Registers a new message handler for message type.voidregisterHandler(String type, java.util.function.BiFunction<io.atomix.utils.net.Address,byte[],CompletableFuture<byte[]>> handler)Registers a new message handler for message type.default CompletableFuture<byte[]>sendAndReceive(io.atomix.utils.net.Address address, String type, byte[] payload)Sends a message asynchronously and expects a response.CompletableFuture<byte[]>sendAndReceive(io.atomix.utils.net.Address address, String type, byte[] payload, boolean keepAlive)Sends a message asynchronously and expects a response.CompletableFuture<byte[]>sendAndReceive(io.atomix.utils.net.Address address, String type, byte[] payload, boolean keepAlive, java.time.Duration timeout)Sends a message asynchronously and expects a response.CompletableFuture<byte[]>sendAndReceive(io.atomix.utils.net.Address address, String type, byte[] payload, boolean keepAlive, java.time.Duration timeout, Executor executor)Sends a message synchronously and expects a response.CompletableFuture<byte[]>sendAndReceive(io.atomix.utils.net.Address address, String type, byte[] payload, boolean keepAlive, Executor executor)Sends a message synchronously and expects a response.default CompletableFuture<byte[]>sendAndReceive(io.atomix.utils.net.Address address, String type, byte[] payload, java.time.Duration timeout)Sends a message asynchronously and expects a response.default CompletableFuture<byte[]>sendAndReceive(io.atomix.utils.net.Address address, String type, byte[] payload, java.time.Duration timeout, Executor executor)Sends a message synchronously and expects a response.default CompletableFuture<byte[]>sendAndReceive(io.atomix.utils.net.Address address, String type, byte[] payload, Executor executor)Sends a message synchronously and expects a response.default CompletableFuture<Void>sendAsync(io.atomix.utils.net.Address address, String type, byte[] payload)Sends a message asynchronously to the specified communication address.CompletableFuture<Void>sendAsync(io.atomix.utils.net.Address address, String type, byte[] payload, boolean keepAlive)Sends a message asynchronously to the specified communication address.voidunregisterHandler(String type)Unregister current handler, if one exists for message type.
-
Method Details
-
address
io.atomix.utils.net.Address address()Returns the local messaging service address.- Returns:
- the local address
-
sendAsync
default CompletableFuture<Void> sendAsync(io.atomix.utils.net.Address address, String type, byte[] payload)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
CompletableFuture<Void> sendAsync(io.atomix.utils.net.Address address, String type, byte[] payload, boolean keepAlive)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
default CompletableFuture<byte[]> sendAndReceive(io.atomix.utils.net.Address address, String type, byte[] payload)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(io.atomix.utils.net.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(io.atomix.utils.net.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(io.atomix.utils.net.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(io.atomix.utils.net.Address address, String type, byte[] payload, java.time.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(io.atomix.utils.net.Address address, String type, byte[] payload, boolean keepAlive, java.time.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
default CompletableFuture<byte[]> sendAndReceive(io.atomix.utils.net.Address address, String type, byte[] payload, java.time.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.timeout- response timeoutexecutor- executor over which any follow up actions after completion will be executed.- Returns:
- a response future
-
sendAndReceive
CompletableFuture<byte[]> sendAndReceive(io.atomix.utils.net.Address address, String type, byte[] payload, boolean keepAlive, java.time.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
void registerHandler(String type, java.util.function.BiConsumer<io.atomix.utils.net.Address,byte[]> handler, 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(String type, java.util.function.BiFunction<io.atomix.utils.net.Address,byte[],byte[]> handler, 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(String type, java.util.function.BiFunction<io.atomix.utils.net.Address,byte[],CompletableFuture<byte[]>> handler)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
-