public static class AxonServerConnectionFactory.Builder extends Object
AxonServerConnectionFactory instance used to connect to an AxonServer (cluster).
This class is not intended to be instantiated directly, but rather through AxonServerConnectionFactory.forClient(String) or AxonServerConnectionFactory.forClient(String, String).
| Modifier | Constructor and Description |
|---|---|
protected |
Builder(String componentName,
String clientInstanceId)
Initializes a builder with the mandatory parameters: the
componentName and clientInstanceId. |
| Modifier and Type | Method and Description |
|---|---|
AxonServerConnectionFactory |
build()
Builds an
AxonServerConnectionFactory using the setting defined in this builder instance. |
AxonServerConnectionFactory.Builder |
clientTag(String key,
String value)
Configures an additional Tag with given
key and value which describes this client. |
AxonServerConnectionFactory.Builder |
clientTags(Map<String,String> additionalClientTags)
Configures the given
additionalClientTags which describe this client. |
AxonServerConnectionFactory.Builder |
commandPermits(int permits)
Sets the number of messages that a Command Handler may receive before any of them have been processed.
|
AxonServerConnectionFactory.Builder |
connectTimeout(long timeout,
TimeUnit timeUnit)
Sets the timeout within which a connection has to be established with an AxonServer instance.
|
AxonServerConnectionFactory.Builder |
customize(UnaryOperator<io.grpc.ManagedChannelBuilder<?>> customization)
Registers the given
customization, which configures the underling ManagedChannelBuilder used
to set up connections to AxonServer. |
AxonServerConnectionFactory.Builder |
forceReconnectViaRoutingServers(boolean forceReconnectViaRoutingServers)
Indicates whether the connector should always reconnect via the Routing Servers.
|
AxonServerConnectionFactory.Builder |
maxInboundMessageSize(int bytes)
Sets the maximum size for inbound messages.
|
AxonServerConnectionFactory.Builder |
processorInfoUpdateFrequency(long interval,
TimeUnit unit)
Sets the frequency in which the status of all Event Processors is emitted to the Server.
|
AxonServerConnectionFactory.Builder |
queryPermits(int permits)
Sets the number of messages that a Query Handler may receive before any of them have been processed.
|
AxonServerConnectionFactory.Builder |
reconnectInterval(long interval,
TimeUnit timeUnit)
Sets the amount of time to wait in between attempts to connect to AxonServer.
|
AxonServerConnectionFactory.Builder |
routingServers(ServerAddress... serverAddresses)
Provides the addresses of the AxonServer instances used to set up the initial connection.
|
AxonServerConnectionFactory.Builder |
threadPoolSize(int poolSize)
Defines the number of Threads that should be used for Connection Management activities by this connector.
|
AxonServerConnectionFactory.Builder |
token(String token)
Defines the token used to authorize activity from this component on AxonServer.
|
AxonServerConnectionFactory.Builder |
useTransportSecurity()
Configures the use of Transport Layer Security (TLS) using the default settings from the JVM.
|
AxonServerConnectionFactory.Builder |
useTransportSecurity(io.netty.handler.ssl.SslContext sslContext)
Configures the use of Transport Layer Security (TLS) using the settings from the given
sslContext. |
AxonServerConnectionFactory.Builder |
usingKeepAlive(long interval,
long timeout,
TimeUnit timeUnit,
boolean keepAliveWithoutCalls)
Sets the time without read activity before sending a keepalive ping.
|
protected void |
validate()
Validates the state of the builder, setting defaults where necessary.
|
protected Builder(String componentName, String clientInstanceId)
componentName and clientInstanceId.componentName - The name of the component connecting to AxonServerclientInstanceId - The unique instance identifier for this instance of the componentpublic AxonServerConnectionFactory.Builder routingServers(ServerAddress... serverAddresses)
The addresses are tried in the order provided, until one send a successful reply.
Defaults to "localhost:8024".
serverAddresses - The addresses to try to set up the initial connection with.public AxonServerConnectionFactory.Builder reconnectInterval(long interval, TimeUnit timeUnit)
routingServers(ServerAddress...)).
Defaults to 2 seconds.
interval - The amount of time to wait in between connection attemptstimeUnit - The unit in which the interval is expressedpublic AxonServerConnectionFactory.Builder connectTimeout(long timeout, TimeUnit timeUnit)
Defaults to 10 seconds.
timeout - The amount of time to wait for a connection to be establishedtimeUnit - The unit in which the timout is expressedpublic AxonServerConnectionFactory.Builder clientTags(Map<String,String> additionalClientTags)
additionalClientTags which describe this client. Any existing tags with the same
key as any of the additional tags provided, will be overwritten.
Tags are used to locate the best matching AxonServer instance to connect with. The instance with the most matching Tags (both key and value must be equal) will be selected.
By default, no tags are defined.
additionalClientTags - additional tags that define this client componentpublic AxonServerConnectionFactory.Builder clientTag(String key, String value)
key and value which describes this client. Any
existing tags with the same key will be overwritten.
Tags are used to locate the best matching AxonServer instance to connect with. The instance with the most matching Tags (both key and value must be equal) will be selected.
By default, no tags are defined.
key - the key of the Tag to configurevalue - the value of the Tag to configurepublic AxonServerConnectionFactory.Builder token(String token)
Defaults to not using a Token. Defining a Token is mandatory when token-based authentication is enabled on AxonServer.
token - The token to which the required authorizations have been assigned.public AxonServerConnectionFactory.Builder useTransportSecurity()
Defaults to not using TLS.
useTransportSecurity(SslContext)public AxonServerConnectionFactory.Builder useTransportSecurity(io.netty.handler.ssl.SslContext sslContext)
sslContext.
Defaults to not using TLS.
sslContext - The context defining TLS parametersSslContextBuilder.forClient()public AxonServerConnectionFactory.Builder forceReconnectViaRoutingServers(boolean forceReconnectViaRoutingServers)
true (default),
the connector will contact the Routing Servers for a new destination each time a connection is dropped. When
false, the connector will first attempt to re-establish a connection to the node is was
previously connected to. When that fails, only then will it contact the Routing Servers.
Default to true, forcing the failed connection to be abandoned and a new one to be requested via the
routing servers.
forceReconnectViaRoutingServers - whether to force a reconnect to the Cluster via the RoutingServers.public AxonServerConnectionFactory.Builder threadPoolSize(int poolSize)
Defaults to 2.
poolSize - The number of threads to assign to Connection related activities.public AxonServerConnectionFactory.Builder usingKeepAlive(long interval, long timeout, TimeUnit timeUnit, boolean keepAliveWithoutCalls)
If no read activity is recorded within the given timeout after sending a keepalive ping, the connection is considered dead.
Clients must receive permission from the service owner before enabling this option. Keepalives can increase the load on services and are commonly "invisible" making it hard to notice when they are causing excessive load. Clients are strongly encouraged to use only as small of a value as necessary.
interval - time without read activity before sending a keepalive pingtimeout - the time waiting for read activity after sending a keepalive pingtimeUnit - the unit in which the interval and timeout are expressedpublic AxonServerConnectionFactory.Builder maxInboundMessageSize(int bytes)
Default to 4 MiB.
bytes - The number of bytes to limit inbound message topublic AxonServerConnectionFactory.Builder customize(UnaryOperator<io.grpc.ManagedChannelBuilder<?>> customization)
customization, which configures the underling ManagedChannelBuilder used
to set up connections to AxonServer.
This method may be used in case none of the operations on this Builder provide support for the required feature.
customization - A function defining the customization to make on the ManagedChannelBuilderpublic AxonServerConnectionFactory.Builder processorInfoUpdateFrequency(long interval, TimeUnit unit)
interval - The interval in which to send status updatesunit - The unit of time in which the interval is expressedpublic AxonServerConnectionFactory.Builder queryPermits(int permits)
Values lower than 16 will be replaced with 16.
permits - The number of initial permitspublic AxonServerConnectionFactory.Builder commandPermits(int permits)
Values lower than 16 will be replaced with 16.
permits - The number of initial permitsprotected void validate()
This method is protected to allow overriding by subclasses. Subclasses are recommended to call this method as part of their own validation process.
public AxonServerConnectionFactory build()
AxonServerConnectionFactory using the setting defined in this builder instance.Copyright © 2020–2023 AxonIQ BV. All rights reserved.