Class ControlChannelImpl
- java.lang.Object
-
- io.axoniq.axonserver.connector.impl.AbstractAxonServerChannel<PlatformInboundInstruction>
-
- io.axoniq.axonserver.connector.impl.ControlChannelImpl
-
- All Implemented Interfaces:
ControlChannel
public class ControlChannelImpl extends AbstractAxonServerChannel<PlatformInboundInstruction> implements ControlChannel
ControlChannelimplementation, serving as the overall control and instruction connection between AxonServer and a client application.
-
-
Constructor Summary
Constructors Constructor Description ControlChannelImpl(ClientIdentification clientIdentification, String context, ScheduledExecutorService executor, AxonServerManagedChannel channel, long processorInfoUpdateFrequency, Runnable reconnectHandler)Constructs aControlChannelImpl.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidconnect()Connect this channel with AxonServer.voiddisableHeartbeat()Disable any previously enabled heartbeats.voiddisconnect()Disconnect this channel from AxonServer.voidenableHeartbeat(long interval, long timeout, TimeUnit timeUnit)Enables sending heartbeat message to validate that the connection to AxonServer is alive.booleanisReady()Validate whether this channel has all required streams connected with AxonServer.voidreconnect()Reconnect this channel with AxonServer.RegistrationregisterEventProcessor(String processorName, Supplier<EventProcessorInfo> infoSupplier, ProcessorInstructionHandler instructionHandler)Registers an Event Processor with AxonServer, allowing AxonServer to request status information and provide instructions for the Processor.RegistrationregisterInstructionHandler(PlatformOutboundInstruction.RequestCase type, InstructionHandler<PlatformOutboundInstruction,PlatformInboundInstruction> handler)Registers the givenhandlerto handle a giventypeof instruction.RegistrationregisterTopologyChangeHandler(Consumer<TopologyChange> handler)Registers a handler for changes in the topology of AxonServer.CompletableFuture<Void>sendInstruction(PlatformInboundInstruction instruction)Send a the giveninstructionover this channel, returning the acknowledgment of theinstructionasynchronously.-
Methods inherited from class io.axoniq.axonserver.connector.impl.AbstractAxonServerChannel
processAck, scheduleImmediateReconnect, scheduleReconnect, sendInstruction
-
-
-
-
Constructor Detail
-
ControlChannelImpl
public ControlChannelImpl(ClientIdentification clientIdentification, String context, ScheduledExecutorService executor, AxonServerManagedChannel channel, long processorInfoUpdateFrequency, Runnable reconnectHandler)
Constructs aControlChannelImpl.- Parameters:
clientIdentification- the information identifying the client application which is connecting. This information is used to pass on to messagecontext- the context thisControlChanneloperates inexecutor- aScheduledExecutorServiceused to schedule reconnects of this channel, heartbeat message dispatching and processor information updateschannel- theAxonServerManagedChannelused to form the connection with AxonServerprocessorInfoUpdateFrequency- the update frequency in milliseconds of event processor informationreconnectHandler- operation run when a reconnect request is received for this channel
-
-
Method Detail
-
connect
public void connect()
Description copied from class:AbstractAxonServerChannelConnect this channel with AxonServer.- Specified by:
connectin classAbstractAxonServerChannel<PlatformInboundInstruction>
-
reconnect
public void reconnect()
Description copied from class:AbstractAxonServerChannelReconnect this channel with AxonServer.- Specified by:
reconnectin classAbstractAxonServerChannel<PlatformInboundInstruction>
-
disconnect
public void disconnect()
Description copied from class:AbstractAxonServerChannelDisconnect this channel from AxonServer.- Specified by:
disconnectin classAbstractAxonServerChannel<PlatformInboundInstruction>
-
registerInstructionHandler
public Registration registerInstructionHandler(PlatformOutboundInstruction.RequestCase type, InstructionHandler<PlatformOutboundInstruction,PlatformInboundInstruction> handler)
Description copied from interface:ControlChannelRegisters the givenhandlerto handle a giventypeof instruction. Any previous registrations of handlers for the given type of instruction are overwritten.Note that de-registration of a handler will not reinstate any previously registered handler for the same type of instruction.
This method is intended to overwrite the default behavior for incoming instructions, or to provide support for non-default instructions.
- Specified by:
registerInstructionHandlerin interfaceControlChannel- Parameters:
type- the type of instructions to handlehandler- the handler to invoke for incoming instructions- Returns:
- a handle to deregister this instruction handler
-
registerTopologyChangeHandler
public Registration registerTopologyChangeHandler(Consumer<TopologyChange> handler)
Description copied from interface:ControlChannelRegisters a handler for changes in the topology of AxonServer. This handler will be invoked whenever there is a change in the topology, such as a new command or query handler being registered, or a handler being deregistered.- Specified by:
registerTopologyChangeHandlerin interfaceControlChannel- Parameters:
handler- for changes in the topology of AxonServer.- Returns:
- a handle to deregister the topology change handler
-
registerEventProcessor
public Registration registerEventProcessor(String processorName, Supplier<EventProcessorInfo> infoSupplier, ProcessorInstructionHandler instructionHandler)
Description copied from interface:ControlChannelRegisters an Event Processor with AxonServer, allowing AxonServer to request status information and provide instructions for the Processor.- Specified by:
registerEventProcessorin interfaceControlChannel- Parameters:
processorName- the name of the processorinfoSupplier- supplier for up-to-date status information of the processorinstructionHandler- handler for incoming instructions for the processor- Returns:
- a handle to cancel the registration of the event processor
-
enableHeartbeat
public void enableHeartbeat(long interval, long timeout, TimeUnit timeUnit)Description copied from interface:ControlChannelEnables sending heartbeat message to validate that the connection to AxonServer is alive. This ensures a fully operational end-to-end connection with AxonServer.When enabled, the client will abandon any connections on which no timely response to a heartbeat has been received. If heartbeats are also enabled on the AxonServer side, any heartbeat initiated by AxonServer will count as a valid connection confirmation.
Consecutive invocations of this method will alter the configuration, resetting heartbeat timers and reinitialize the heartbeat processing.
- Specified by:
enableHeartbeatin interfaceControlChannel- Parameters:
interval- the interval at which heartbeat messages are expectedtimeout- the maximum time to wait for a confirmation after initiating a heartbeat messagetimeUnit- the unit of time in which interval and timeout are expressed
-
disableHeartbeat
public void disableHeartbeat()
Description copied from interface:ControlChannelDisable any previously enabled heartbeats. Heartbeat requests initiated by AxonServer will still be reacted to, but the client will no longer initiate a heartbeat, nor close a connection when it fails to receive confirmations.- Specified by:
disableHeartbeatin interfaceControlChannel
-
sendInstruction
public CompletableFuture<Void> sendInstruction(PlatformInboundInstruction instruction)
Description copied from interface:ControlChannelSend a the giveninstructionover this channel, returning the acknowledgment of theinstructionasynchronously.- Specified by:
sendInstructionin interfaceControlChannel- Parameters:
instruction- thePlatformInboundInstructionto send over this channel- Returns:
- a
CompletableFutureof the acknowledgement of the giveninstruction
-
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<PlatformInboundInstruction>- Returns:
trueif this channel is connected with AxonServer or does not require any active connections,falseotherwise
-
-