Class DistributedCommandBus.Builder
java.lang.Object
org.axonframework.commandhandling.distributed.DistributedCommandBus.Builder
- Enclosing class:
DistributedCommandBus
Builder class to instantiate a
DistributedCommandBus.
The CommandCallback is defaulted to a LoggingCallback. The MessageMonitor is defaulted to
a NoOpMessageMonitor. The CommandBusSpanFactory is defaulted to a
DefaultCommandBusSpanFactory backed by a NoOpSpanFactory. The CommandRouter and
CommandBusConnector are hard requirements and as such should be provided.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Initializes aDistributedCommandBusas specified through this Builder.commandRouter(CommandRouter commandRouter) Sets theCommandRouterused to determine the target node for each dispatched command.connector(CommandBusConnector connector) Sets theCommandBusConnectorwhich performs the actual transport of the message to the destination node.defaultCommandCallback(CommandCallback<Object, Object> defaultCommandCallback) Sets the callback to use when commands are dispatched in a "fire and forget" method, such asDistributedCommandBus.dispatch(CommandMessage).messageMonitor(MessageMonitor<? super CommandMessage<?>> messageMonitor) Sets theMessageMonitorfor generic types implementingCommandMessage, which is used to monitor incoming messages and their execution result.spanFactory(CommandBusSpanFactory spanFactory) Sets theCommandBusSpanFactoryimplementation to use for providing tracing capabilities.spanFactory(SpanFactory spanFactory) Deprecated.protected voidvalidate()Validate whether the fields contained in this Builder as set accordingly.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
commandRouter
Sets theCommandRouterused to determine the target node for each dispatched command.- Parameters:
commandRouter- aCommandRouterused to determine the target node for each dispatched command- Returns:
- the current Builder instance, for fluent interfacing
-
connector
Sets theCommandBusConnectorwhich performs the actual transport of the message to the destination node.- Parameters:
connector- aCommandBusConnectorwhich performs the actual transport of the message to the destination node- Returns:
- the current Builder instance, for fluent interfacing
-
messageMonitor
public DistributedCommandBus.Builder messageMonitor(MessageMonitor<? super CommandMessage<?>> messageMonitor) Sets theMessageMonitorfor generic types implementingCommandMessage, which is used to monitor incoming messages and their execution result.- Parameters:
messageMonitor- aMessageMonitorused to monitor incoming messages and their execution result- Returns:
- the current Builder instance, for fluent interfacing
-
defaultCommandCallback
public DistributedCommandBus.Builder defaultCommandCallback(CommandCallback<Object, Object> defaultCommandCallback) Sets the callback to use when commands are dispatched in a "fire and forget" method, such asDistributedCommandBus.dispatch(CommandMessage). Defaults to using a logging callback, which requests the connectors to use a fire-and-forget strategy for dispatching event.- Parameters:
defaultCommandCallback- the callback to invoke when no explicit callback is provided for a command- Returns:
- the current Builder instance, for fluent interfacing
-
spanFactory
Deprecated.UsespanFactory(CommandBusSpanFactory)instead as it provides more configurability.Sets theSpanFactoryimplementation to use for providing tracing capabilities. Defaults to aNoOpSpanFactoryby default, which provides no tracing capabilities.- Parameters:
spanFactory- TheSpanFactoryimplementation- Returns:
- The current Builder instance, for fluent interfacing.
-
spanFactory
Sets theCommandBusSpanFactoryimplementation to use for providing tracing capabilities. Defaults to aDefaultCommandBusSpanFactorybacked by aNoOpSpanFactoryby default, which provides no tracing capabilities.- Parameters:
spanFactory- TheCommandBusSpanFactoryimplementation- Returns:
- The current Builder instance, for fluent interfacing.
-
build
Initializes aDistributedCommandBusas specified through this Builder.- Returns:
- a
DistributedCommandBusas specified through this Builder
-
validate
protected void validate()Validate whether the fields contained in this Builder as set accordingly.- Throws:
AxonConfigurationException- if one field is asserted to be incorrect according to the Builder's specifications
-
spanFactory(CommandBusSpanFactory)instead as it provides more configurability.