public static class AxonServerCommandBus.Builder extends Object
AxonServerCommandBus
.
The CommandPriorityCalculator
is defaulted to CommandPriorityCalculator.defaultCommandPriorityCalculator()
and the TargetContextResolver
defaults to a lambda returning the AxonServerConfiguration.getContext()
as the context. The ExecutorServiceBuilder
defaults to ExecutorServiceBuilder.defaultCommandExecutorServiceBuilder()
. The AxonServerConnectionManager
, the
AxonServerConfiguration
, the local CommandBus
, Serializer
and the RoutingStrategy
are hard requirements and as such should be provided.
Constructor and Description |
---|
Builder() |
Modifier and Type | Method and Description |
---|---|
AxonServerCommandBus.Builder |
axonServerConnectionManager(AxonServerConnectionManager axonServerConnectionManager)
Sets the
AxonServerConnectionManager used to create connections between this application and an Axon
Server instance. |
AxonServerCommandBus |
build()
Initializes a
AxonServerCommandBus as specified through this Builder. |
protected CommandSerializer |
buildSerializer()
|
AxonServerCommandBus.Builder |
configuration(AxonServerConfiguration configuration)
Sets the
AxonServerConfiguration used to configure several components within the Axon Server Command
Bus, like setting the client id or the number of command handling threads used. |
AxonServerCommandBus.Builder |
defaultCommandCallback(CommandCallback<Object,Object> defaultCommandCallback)
Sets the callback to use when commands are dispatched in a "fire and forget" method, such as
AxonServerCommandBus.dispatch(CommandMessage) . |
AxonServerCommandBus.Builder |
executorServiceBuilder(ExecutorServiceBuilder executorServiceBuilder)
Sets the
ExecutorServiceBuilder which builds an ExecutorService based on a given AxonServerConfiguration and BlockingQueue of Runnable . |
AxonServerCommandBus.Builder |
loadFactorProvider(CommandLoadFactorProvider loadFactorProvider)
Sets the
CommandLoadFactorProvider which provides the load factor values for all commands this client
can handle. |
AxonServerCommandBus.Builder |
localSegment(CommandBus localSegment)
Sets the local
CommandBus used to dispatch incoming commands to the local environment. |
AxonServerCommandBus.Builder |
priorityCalculator(CommandPriorityCalculator priorityCalculator)
Sets the
CommandPriorityCalculator used to deduce the priority of an incoming command among other
commands, to give precedence over high(er) valued queries for example. |
AxonServerCommandBus.Builder |
routingStrategy(RoutingStrategy routingStrategy)
Sets the
RoutingStrategy used to correctly configure connections between Axon clients and Axon
Server. |
AxonServerCommandBus.Builder |
serializer(Serializer serializer)
Sets the
Serializer used to de-/serialize incoming and outgoing commands and command results. |
AxonServerCommandBus.Builder |
targetContextResolver(TargetContextResolver<? super CommandMessage<?>> targetContextResolver)
Sets the
TargetContextResolver used to resolve the target (bounded) context of an ingested CommandMessage . |
protected void |
validate()
Validates whether the fields contained in this Builder are set accordingly.
|
public AxonServerCommandBus.Builder axonServerConnectionManager(AxonServerConnectionManager axonServerConnectionManager)
AxonServerConnectionManager
used to create connections between this application and an Axon
Server instance.axonServerConnectionManager
- an AxonServerConnectionManager
used to create connections between
this application and an Axon Server instancepublic AxonServerCommandBus.Builder configuration(AxonServerConfiguration configuration)
AxonServerConfiguration
used to configure several components within the Axon Server Command
Bus, like setting the client id or the number of command handling threads used.configuration
- an AxonServerConfiguration
used to configure several components within the Axon
Server Command Buspublic AxonServerCommandBus.Builder localSegment(CommandBus localSegment)
CommandBus
used to dispatch incoming commands to the local environment.localSegment
- a CommandBus
used to dispatch incoming commands to the local environmentpublic AxonServerCommandBus.Builder serializer(Serializer serializer)
Serializer
used to de-/serialize incoming and outgoing commands and command results.serializer
- a Serializer
used to de-/serialize incoming and outgoing commands and command
resultspublic AxonServerCommandBus.Builder routingStrategy(RoutingStrategy routingStrategy)
RoutingStrategy
used to correctly configure connections between Axon clients and Axon
Server.routingStrategy
- a RoutingStrategy
public AxonServerCommandBus.Builder defaultCommandCallback(CommandCallback<Object,Object> defaultCommandCallback)
AxonServerCommandBus.dispatch(CommandMessage)
. Defaults to a NoOpCallback
. Passing null
will result in a NoOpCallback
being used.defaultCommandCallback
- the callback to invoke when no explicit callback is provided for a commandpublic AxonServerCommandBus.Builder priorityCalculator(CommandPriorityCalculator priorityCalculator)
CommandPriorityCalculator
used to deduce the priority of an incoming command among other
commands, to give precedence over high(er) valued queries for example. Defaults to a CommandPriorityCalculator.defaultCommandPriorityCalculator()
.priorityCalculator
- a CommandPriorityCalculator
used to deduce the priority of an incoming
command among other commandspublic AxonServerCommandBus.Builder targetContextResolver(TargetContextResolver<? super CommandMessage<?>> targetContextResolver)
TargetContextResolver
used to resolve the target (bounded) context of an ingested CommandMessage
. Defaults to returning the AxonServerConfiguration.getContext()
on any type of
command message being ingested.targetContextResolver
- a TargetContextResolver
used to resolve the target (bounded) context of
an ingested CommandMessage
public AxonServerCommandBus.Builder executorServiceBuilder(ExecutorServiceBuilder executorServiceBuilder)
ExecutorServiceBuilder
which builds an ExecutorService
based on a given AxonServerConfiguration
and BlockingQueue
of Runnable
. This ExecutorService is used to
process incoming commands with. Defaults to a ThreadPoolExecutor
, using the AxonServerConfiguration.getCommandThreads()
for the pool size, a keep-alive-time of 100ms
, the given
BlockingQueue as the work queue and an AxonThreadFactory
.
Note that it is highly recommended to use the given BlockingQueue if you are to provide you own executorServiceBuilder
, as it ensure the command's priority is taken into consideration. Defaults to ExecutorServiceBuilder.defaultCommandExecutorServiceBuilder()
.executorServiceBuilder
- an ExecutorServiceBuilder
used to build an ExecutorService
based on the AxonServerConfiguration
and a BlockingQueue
public AxonServerCommandBus.Builder loadFactorProvider(CommandLoadFactorProvider loadFactorProvider)
CommandLoadFactorProvider
which provides the load factor values for all commands this client
can handle. The load factor values are sent to AxonServer during command subscription. AxonServer uses these
values to balance the dispatching of commands among the client instances. The default implementation of
loadFactorProvider returns always CommandLoadFactorProvider.DEFAULT_VALUE
loadFactorProvider
- a CommandLoadFactorProvider
used to get the load factor value for each
specific command that this client can handlepublic AxonServerCommandBus build()
AxonServerCommandBus
as specified through this Builder.AxonServerCommandBus
as specified through this Builderprotected CommandSerializer buildSerializer()
CommandSerializer
based on the configured serializer
and configuration
protected void validate() throws AxonConfigurationException
AxonConfigurationException
- if one field is asserted to be incorrect according to the Builder's
specificationsCopyright © 2010–2020. All rights reserved.