Package io.axoniq.axonserver.connector
Class AxonServerConnectionFactory
- java.lang.Object
-
- io.axoniq.axonserver.connector.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 creatingChannels per context and providing them as the means to dispatch/receive messages.- Since:
- 4.0
- Author:
- Marc Gathier
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classAxonServerConnectionFactory.BuilderBuilder for AxonServerConnectionFactory instances.
-
Constructor Summary
Constructors Modifier Constructor Description protectedAxonServerConnectionFactory(AxonServerConnectionFactory.Builder builder)Instantiates anAxonServerConnectionFactorywith the givenbuilder.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description AxonServerConnectionconnect(String context)Connects to the givencontextusing the settings defined in this ConnectionFactory.static AxonServerConnectionFactory.BuilderforClient(String componentName)Returns a builder to configure a ConnectionFactory instance for the givencomponentName.static AxonServerConnectionFactory.BuilderforClient(String componentName, String clientInstanceId)Returns a builder to configure a ConnectionFactory instance for the givencomponentNameandclientInstanceId.StringgetClientInstanceId()Returns the unique client instance identifier used by this ConnectionFactory.voidshutdown()Shuts down the connector, disconnecting from all contexts.
-
-
-
Constructor Detail
-
AxonServerConnectionFactory
protected AxonServerConnectionFactory(AxonServerConnectionFactory.Builder builder)
Instantiates anAxonServerConnectionFactorywith the givenbuilder. The clientInstanceId is postfixed by a random hex string to ensure uniqueness between different instances of the application.- Parameters:
builder- theAxonServerConnectionFactory.Builderused to set all the specifics of anAxonServerConnectionFactory
-
-
Method Detail
-
forClient
public static AxonServerConnectionFactory.Builder forClient(String componentName)
Returns a builder to configure a ConnectionFactory instance for the givencomponentName.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 givencomponentNameandclientInstanceId.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
clientInstanceIdremains the same across restarts of a component instance.- Parameters:
componentName- The name of the component connecting to AxonServerclientInstanceId- 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 givencontextusing 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 asclientInstanceIdon 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
-
-