public class CommandChannelImpl extends AbstractAxonServerChannel<CommandProviderOutbound> implements CommandChannel
CommandChannel implementation, serving as the command connection between AxonServer and a client
application.| Constructor and Description |
|---|
CommandChannelImpl(ClientIdentification clientIdentification,
String context,
int permits,
int permitsBatch,
ScheduledExecutorService executor,
AxonServerManagedChannel channel)
Constructs a
CommandChannelImpl. |
| Modifier and Type | Method and Description |
|---|---|
void |
connect()
Connect this channel with AxonServer.
|
void |
disconnect()
Disconnect this channel from AxonServer.
|
boolean |
isReady()
Validate whether this channel has all required streams connected with AxonServer.
|
CompletableFuture<Void> |
prepareDisconnect()
Prepares this
CommandChannel to disconnect, by unsubscribing all registered command handlers. |
void |
reconnect()
Reconnect this channel with AxonServer.
|
Registration |
registerCommandHandler(Function<Command,CompletableFuture<CommandResponse>> handler,
int loadFactor,
String... commandNames)
Registers the given
handler to handle incoming commands with given commandNames, using the given
loadFactor. |
CompletableFuture<CommandResponse> |
sendCommand(Command command)
Sends the give Command to AxonServer for routing to an appropriate handler.
|
processAck, scheduleImmediateReconnect, scheduleReconnect, sendInstructionpublic CommandChannelImpl(ClientIdentification clientIdentification, String context, int permits, int permitsBatch, ScheduledExecutorService executor, AxonServerManagedChannel channel)
CommandChannelImpl.clientIdentification - client information identifying whom has connected. This information is used to pass
on to messagepermits - an int defining the number of permits this channel haspermitsBatch - an int defining the number of permits to be consumed from prior to requesting
additional permits for this channelexecutor - a ScheduledExecutorService used to schedule reconnects of this channelchannel - the AxonServerManagedChannel used to form the connection with AxonServerpublic void connect()
AbstractAxonServerChannelconnect in class AbstractAxonServerChannel<CommandProviderOutbound>public void reconnect()
AbstractAxonServerChannelreconnect in class AbstractAxonServerChannel<CommandProviderOutbound>public void disconnect()
AbstractAxonServerChanneldisconnect in class AbstractAxonServerChannel<CommandProviderOutbound>public boolean isReady()
AbstractAxonServerChanneltrue.isReady in class AbstractAxonServerChannel<CommandProviderOutbound>true if this channel is connected with AxonServer or does not require any active connections,
false otherwisepublic Registration registerCommandHandler(Function<Command,CompletableFuture<CommandResponse>> handler, int loadFactor, String... commandNames)
CommandChannelhandler to handle incoming commands with given commandNames, using the given
loadFactor. If handlers had already been registered for any of the given command names, this registration
replaces the existing one for those command names. Other commands remain unaffected.registerCommandHandler in interface CommandChannelhandler - the handler to handle incoming commands withloadFactor - the relative load factor for this handlercommandNames - the names of the commands to register the handler forpublic CompletableFuture<CommandResponse> sendCommand(Command command)
CommandChannelsendCommand in interface CommandChannelcommand - the command to sendpublic CompletableFuture<Void> prepareDisconnect()
CommandChannelCommandChannel to disconnect, by unsubscribing all registered command handlers. Will wait
with a certain cut off until all acknowledgments of unsubscribing have been received.
This method should be used if a connected client wants to disconnect from AxonServer.
prepareDisconnect in interface CommandChannelCompletableFuture of Void to react when all command handlers have been unsubscribedCopyright © 2020–2023 AxonIQ BV. All rights reserved.