Class AxonServerConnectionFactory


  • public class AxonServerConnectionFactory
    extends Object
    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
    Author:
    Marc Gathier
    • Method Detail

      • forClient

        public static AxonServerConnectionFactory.Builder forClient​(String componentName)
        Returns a builder to configure a ConnectionFactory instance for the given componentName.

        A unique clientInstanceId will be generated for this component. The componentName is used in monitoring information and should be the same only for instances of the same application or component.

        Parameters:
        componentName - The name of the component connecting to AxonServer
        Returns:
        a builder instance for further configuration of the connector
        See Also:
        forClient(String, String)
      • forClient

        public static AxonServerConnectionFactory.Builder forClient​(String componentName,
                                                                    String clientInstanceId)
        Returns a builder to configure a ConnectionFactory instance for the given componentName and clientInstanceId.

        The clientInstanceId MUST be a unique value across all instances that connect to AxonServer. The componentName is used in monitoring information and should be the same only for instances of the same application or component.

        Where possible, it is preferable that the clientInstanceId remains the same across restarts of a component instance.

        Parameters:
        componentName - The name of the component connecting to AxonServer
        clientInstanceId - The unique instance identifier for this instance of the component
        Returns:
        a builder instance for further configuration of the connector
        See Also:
        forClient(String)
      • connect

        public AxonServerConnection connect​(String context)
        Connects to the given context using the settings defined in this ConnectionFactory.
        Parameters:
        context - The name of the context to connect to
        Returns:
        a Connection allowing interaction with the mentioned context
      • shutdown

        public void shutdown()
        Shuts down the connector, disconnecting from all contexts. To reconnect after calling this method, a new instance of the ConnectionFactory needs to be created.

        In case where regular reconnection is required, consider using AxonServerConnection.disconnect() on the connections created by this factory instead.

        See Also:
        AxonServerConnection.disconnect()
      • getClientInstanceId

        public String getClientInstanceId()
        Returns the unique client instance identifier used by this ConnectionFactory. This is the value configured as clientInstanceId on the Builder, postfixed with a random hex string to ensure uniqueness between different instances of the application.
        Returns:
        the unique client instance identifier used by this ConnectionFactory