Class CommandChannelImpl
- java.lang.Object
-
- io.axoniq.axonserver.connector.impl.AbstractAxonServerChannel<CommandProviderOutbound>
-
- io.axoniq.axonserver.connector.command.impl.CommandChannelImpl
-
- All Implemented Interfaces:
CommandChannel
public class CommandChannelImpl extends AbstractAxonServerChannel<CommandProviderOutbound> implements CommandChannel
CommandChannelimplementation, serving as the command connection between AxonServer and a client application.
-
-
Constructor Summary
Constructors Constructor Description CommandChannelImpl(ClientIdentification clientIdentification, String context, int permits, int permitsBatch, ScheduledExecutorService executor, AxonServerManagedChannel channel)Constructs aCommandChannelImpl.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconnect()Connect this channel with AxonServer.voiddisconnect()Disconnect this channel from AxonServer.booleanisReady()Validate whether this channel has all required streams connected with AxonServer.CompletableFuture<Void>prepareDisconnect()Prepares thisCommandChannelto disconnect, by unsubscribing all registered command handlers.voidreconnect()Reconnect this channel with AxonServer.RegistrationregisterCommandHandler(Function<Command,CompletableFuture<CommandResponse>> handler, int loadFactor, String... commandNames)Registers the givenhandlerto handle incoming commands with givencommandNames, using the givenloadFactor.CompletableFuture<CommandResponse>sendCommand(Command command)Sends the give Command to AxonServer for routing to an appropriate handler.-
Methods inherited from class io.axoniq.axonserver.connector.impl.AbstractAxonServerChannel
processAck, scheduleImmediateReconnect, scheduleReconnect, sendInstruction
-
-
-
-
Constructor Detail
-
CommandChannelImpl
public CommandChannelImpl(ClientIdentification clientIdentification, String context, int permits, int permitsBatch, ScheduledExecutorService executor, AxonServerManagedChannel channel)
Constructs aCommandChannelImpl.- Parameters:
clientIdentification- client information identifying whom has connected. This information is used to pass on to messagepermits- anintdefining the number of permits this channel haspermitsBatch- anintdefining the number of permits to be consumed from prior to requesting additional permits for this channelexecutor- aScheduledExecutorServiceused to schedule reconnects of this channelchannel- theAxonServerManagedChannelused to form the connection with AxonServer
-
-
Method Detail
-
connect
public void connect()
Description copied from class:AbstractAxonServerChannelConnect this channel with AxonServer.- Specified by:
connectin classAbstractAxonServerChannel<CommandProviderOutbound>
-
reconnect
public void reconnect()
Description copied from class:AbstractAxonServerChannelReconnect this channel with AxonServer.- Specified by:
reconnectin classAbstractAxonServerChannel<CommandProviderOutbound>
-
disconnect
public void disconnect()
Description copied from class:AbstractAxonServerChannelDisconnect this channel from AxonServer.- Specified by:
disconnectin classAbstractAxonServerChannel<CommandProviderOutbound>
-
isReady
public boolean isReady()
Description copied from class:AbstractAxonServerChannelValidate whether this channel has all required streams connected with AxonServer. If the state of the channel does not require any active streams, it is considered ready and will returntrue.- Specified by:
isReadyin classAbstractAxonServerChannel<CommandProviderOutbound>- Returns:
trueif this channel is connected with AxonServer or does not require any active connections,falseotherwise
-
registerCommandHandler
public Registration registerCommandHandler(Function<Command,CompletableFuture<CommandResponse>> handler, int loadFactor, String... commandNames)
Description copied from interface:CommandChannelRegisters the givenhandlerto handle incoming commands with givencommandNames, using the givenloadFactor. 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.- Specified by:
registerCommandHandlerin interfaceCommandChannel- Parameters:
handler- the handler to handle incoming commands withloadFactor- the relative load factor for this handlercommandNames- the names of the commands to register the handler for- Returns:
- a registration which allows the command handler to be deregistered
-
sendCommand
public CompletableFuture<CommandResponse> sendCommand(Command command)
Description copied from interface:CommandChannelSends the give Command to AxonServer for routing to an appropriate handler.- Specified by:
sendCommandin interfaceCommandChannel- Parameters:
command- the command to send- Returns:
- a CompletableFuture providing the result of command execution
-
prepareDisconnect
public CompletableFuture<Void> prepareDisconnect()
Description copied from interface:CommandChannelPrepares thisCommandChannelto 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.
- Specified by:
prepareDisconnectin interfaceCommandChannel- Returns:
- a
CompletableFutureofVoidto react when all command handlers have been unsubscribed
-
-