Class AxonServerConnectionManager

java.lang.Object
org.axonframework.axonserver.connector.AxonServerConnectionManager
All Implemented Interfaces:
ConnectionManager

public class AxonServerConnectionManager extends Object implements ConnectionManager
The component which manages all the connections which an Axon client can establish with an Axon Server instance. Does so by creating Channels per context and providing them as the means to dispatch/receive messages.
Since:
4.0.0
Author:
Marc Gathier
  • Constructor Details

    • AxonServerConnectionManager

      protected AxonServerConnectionManager(AxonServerConnectionManager.Builder builder, io.axoniq.axonserver.connector.AxonServerConnectionFactory connectionFactory)
      Instantiate a AxonServerConnectionManager based on the fields contained in the AxonServerConnectionManager.Builder, using the given connectionFactory to obtain connections to AxonServer.
      Parameters:
      builder - the AxonServerConnectionManager.Builder used to instantiate a AxonServerConnectionManager instance
      connectionFactory - a configured instance of the AxonServerConnectionFactory
  • Method Details

    • builder

      public static AxonServerConnectionManager.Builder builder()
      Instantiate a Builder to be able to create an AxonServerConnectionManager.

      The routingServers default to "localhost:8024" and the TagsConfiguration is defaulted to TagsConfiguration(). The AxonServerConfiguration is a hard requirements and as such should be provided.

      Returns:
      a Builder to be able to create a AxonServerConnectionManager
    • start

      public void start()
      Starts the AxonServerConnectionManager. Will enable heartbeat messages to be sent to the connected Axon Server instance in the Phase.INSTRUCTION_COMPONENTS phase, if this has been enabled through the AxonServerConfiguration.HeartbeatConfiguration.isEnabled().
    • getConnection

      public io.axoniq.axonserver.connector.AxonServerConnection getConnection()
      Retrieves the AxonServerConnection used for the default context of this application.
      Returns:
      the AxonServerConnection used for the default context of this application
    • getConnection

      public io.axoniq.axonserver.connector.AxonServerConnection getConnection(String context)
      Retrieves the AxonServerConnection used for the given context of this application.
      Parameters:
      context - the context for which to retrieve an AxonServerConnection
      Returns:
      the AxonServerConnection used for the given context of this application.
    • isConnected

      public boolean isConnected(String context)
      Returns true if a gRPC channel for the specific context is opened between client and AxonServer.
      Parameters:
      context - the (Bounded) Context for which is verified the AxonServer connection through the gRPC channel
      Returns:
      if the gRPC channel is opened, false otherwise
    • shutdown

      public void shutdown()
      Stops the Connection Manager, closing any active connections and preventing new connections from being created. This shutdown operation is performed in the Phase.EXTERNAL_CONNECTIONS phase.
    • disconnect

      public void disconnect(String context)
      Disconnects any active connection for the given context, forcing a new connection to be established when one is requested.
      Parameters:
      context - the context for which the connection must be disconnected
    • disconnect

      public void disconnect()
      Disconnects any active connections, forcing a new connection to be established when one is requested.
    • getDefaultContext

      public String getDefaultContext()
      Returns the name of the default context of this application.
      Returns:
      the name of the default context of this application
    • connections

      public Map<String,Boolean> connections()
      Description copied from interface: ConnectionManager
      Return the connections this instances manages. Consists of key-value pairs where the key resembles the context name and the value describes whether the connection is active at this moment.
      Specified by:
      connections in interface ConnectionManager
      Returns:
      Return the connections this instances manages.