Class ControlChannelImpl

    • Constructor Detail

      • ControlChannelImpl

        public ControlChannelImpl​(ClientIdentification clientIdentification,
                                  String context,
                                  ScheduledExecutorService executor,
                                  AxonServerManagedChannel channel,
                                  long processorInfoUpdateFrequency,
                                  Runnable reconnectHandler)
        Constructs a ControlChannelImpl.
        Parameters:
        clientIdentification - the information identifying the client application which is connecting. This information is used to pass on to message
        context - the context this ControlChannel operates in
        executor - a ScheduledExecutorService used to schedule reconnects of this channel, heartbeat message dispatching and processor information updates
        channel - the AxonServerManagedChannel used to form the connection with AxonServer
        processorInfoUpdateFrequency - the update frequency in milliseconds of event processor information
        reconnectHandler - operation run when a reconnect request is received for this channel
    • Method Detail

      • registerInstructionHandler

        public Registration registerInstructionHandler​(PlatformOutboundInstruction.RequestCase type,
                                                       InstructionHandler<PlatformOutboundInstruction,​PlatformInboundInstruction> handler)
        Description copied from interface: ControlChannel
        Registers the given handler to handle a given type of 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:
        registerInstructionHandler in interface ControlChannel
        Parameters:
        type - the type of instructions to handle
        handler - 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: ControlChannel
        Registers 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:
        registerTopologyChangeHandler in interface ControlChannel
        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: ControlChannel
        Registers an Event Processor with AxonServer, allowing AxonServer to request status information and provide instructions for the Processor.
        Specified by:
        registerEventProcessor in interface ControlChannel
        Parameters:
        processorName - the name of the processor
        infoSupplier - supplier for up-to-date status information of the processor
        instructionHandler - 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: ControlChannel
        Enables 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:
        enableHeartbeat in interface ControlChannel
        Parameters:
        interval - the interval at which heartbeat messages are expected
        timeout - the maximum time to wait for a confirmation after initiating a heartbeat message
        timeUnit - the unit of time in which interval and timeout are expressed
      • disableHeartbeat

        public void disableHeartbeat()
        Description copied from interface: ControlChannel
        Disable 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:
        disableHeartbeat in interface ControlChannel
      • isReady

        public boolean isReady()
        Description copied from class: AbstractAxonServerChannel
        Validate 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 return true.
        Specified by:
        isReady in class AbstractAxonServerChannel<PlatformInboundInstruction>
        Returns:
        true if this channel is connected with AxonServer or does not require any active connections, false otherwise