Class AsynchronousCommandBus.Builder
java.lang.Object
org.axonframework.commandhandling.SimpleCommandBus.Builder
org.axonframework.commandhandling.AsynchronousCommandBus.Builder
- Enclosing class:
AsynchronousCommandBus
Builder class to instantiate a
AsynchronousCommandBus.
The TransactionManager, MessageMonitor, RollbackConfiguration,
DuplicateCommandHandlerResolver, CommandBusSpanFactory to a DefaultCommandBusSpanFactory
backed by a NoOpSpanFactory, and Executor are respectively defaulted to
a NoTransactionManager, a NoOpMessageMonitor, a
RollbackConfigurationType.UNCHECKED_EXCEPTIONS, a
DuplicateCommandHandlerResolution.logAndOverride(), NoOpSpanFactory and
a Executors.newCachedThreadPool(). The default executor uses an AxonThreadFactory to create
threads with a sensible naming scheme. The TransactionManager, MessageMonitor, RollbackConfiguration and Executor
are hard requirements. Thus setting them to null will result in an
AxonConfigurationException.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Initializes aAsynchronousCommandBusas specified through this Builder.defaultCommandCallback(CommandCallback<Object, Object> defaultCommandCallback) Sets the callback to use when commands are dispatched in a "fire and forget" method, such asSimpleCommandBus.dispatch(CommandMessage).duplicateCommandHandlerResolver(DuplicateCommandHandlerResolver duplicateCommandHandlerResolver) Sets theDuplicateCommandHandlerResolverused to resolves the road to take when a duplicate command handler is subscribed.Sets theExecutorwhich processes the Command dispatching threads.messageMonitor(MessageMonitor<? super CommandMessage<?>> messageMonitor) Sets theMessageMonitorof generic typeCommandMessageused the to monitor the command bus.rollbackConfiguration(RollbackConfiguration rollbackConfiguration) Sets theRollbackConfigurationwhich allows you to specify when aUnitOfWorkshould be rolled back.spanFactory(CommandBusSpanFactory spanFactory) Sets theCommandBusSpanFactoryimplementation to use for providing tracing capabilities.spanFactory(SpanFactory spanFactory) Sets theSpanFactoryimplementation to use for providing tracing capabilities.transactionManager(TransactionManager transactionManager) Sets theTransactionManagerused to manage transactions.Methods inherited from class org.axonframework.commandhandling.SimpleCommandBus.Builder
validate
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
transactionManager
public AsynchronousCommandBus.Builder transactionManager(@Nonnull TransactionManager transactionManager) Description copied from class:SimpleCommandBus.BuilderSets theTransactionManagerused to manage transactions. Defaults to aNoTransactionManager.- Overrides:
transactionManagerin classSimpleCommandBus.Builder- Parameters:
transactionManager- aTransactionManagerused to manage transactions- Returns:
- the current Builder instance, for fluent interfacing
-
messageMonitor
public AsynchronousCommandBus.Builder messageMonitor(@Nonnull MessageMonitor<? super CommandMessage<?>> messageMonitor) Description copied from class:SimpleCommandBus.BuilderSets theMessageMonitorof generic typeCommandMessageused the to monitor the command bus. Defaults to aNoOpMessageMonitor.- Overrides:
messageMonitorin classSimpleCommandBus.Builder- Parameters:
messageMonitor- aMessageMonitorused the message monitor to monitor the command bus- Returns:
- the current Builder instance, for fluent interfacing
-
rollbackConfiguration
public AsynchronousCommandBus.Builder rollbackConfiguration(@Nonnull RollbackConfiguration rollbackConfiguration) Description copied from class:SimpleCommandBus.BuilderSets theRollbackConfigurationwhich allows you to specify when aUnitOfWorkshould be rolled back. Defaults to aRollbackConfigurationType.UNCHECKED_EXCEPTIONS, which triggers a rollback on all unchecked exceptions.- Overrides:
rollbackConfigurationin classSimpleCommandBus.Builder- Parameters:
rollbackConfiguration- aRollbackConfigurationspecifying when aUnitOfWorkshould be rolled back- Returns:
- the current Builder instance, for fluent interfacing
-
defaultCommandCallback
public AsynchronousCommandBus.Builder defaultCommandCallback(@Nonnull CommandCallback<Object, Object> defaultCommandCallback) Description copied from class:SimpleCommandBus.BuilderSets the callback to use when commands are dispatched in a "fire and forget" method, such asSimpleCommandBus.dispatch(CommandMessage). Defaults to aLoggingCallback. Passingnullwill result in aNoOpCallbackbeing used.- Overrides:
defaultCommandCallbackin classSimpleCommandBus.Builder- Parameters:
defaultCommandCallback- the callback to invoke when no explicit callback is provided for a command- Returns:
- the current Builder instance, for fluent interfacing
-
duplicateCommandHandlerResolver
public AsynchronousCommandBus.Builder duplicateCommandHandlerResolver(@Nonnull DuplicateCommandHandlerResolver duplicateCommandHandlerResolver) Description copied from class:SimpleCommandBus.BuilderSets theDuplicateCommandHandlerResolverused to resolves the road to take when a duplicate command handler is subscribed. Defaults toDuplicateCommandHandlerResolution.logAndOverride().- Overrides:
duplicateCommandHandlerResolverin classSimpleCommandBus.Builder- Parameters:
duplicateCommandHandlerResolver- aDuplicateCommandHandlerResolverused to resolves the road to take when a duplicate command handler is subscribed- Returns:
- the current Builder instance, for fluent interfacing
-
spanFactory
Description copied from class:SimpleCommandBus.BuilderSets theSpanFactoryimplementation to use for providing tracing capabilities. Defaults to aNoOpSpanFactoryby default, which provides no tracing capabilities.- Overrides:
spanFactoryin classSimpleCommandBus.Builder- Parameters:
spanFactory- TheSpanFactoryimplementation.- Returns:
- The current Builder instance, for fluent interfacing.
-
spanFactory
Description copied from class:SimpleCommandBus.BuilderSets theCommandBusSpanFactoryimplementation to use for providing tracing capabilities. Defaults to aDefaultCommandBusSpanFactorybacked byNoOpSpanFactoryby default, which provides no tracing capabilities.- Overrides:
spanFactoryin classSimpleCommandBus.Builder- Parameters:
spanFactory- TheCommandBusSpanFactoryimplementation.- Returns:
- The current Builder instance, for fluent interfacing.
-
executor
Sets theExecutorwhich processes the Command dispatching threads.- Parameters:
executor- aExecutorto processes the Command dispatching threads- Returns:
- the current Builder instance, for fluent interfacing
-
build
Initializes aAsynchronousCommandBusas specified through this Builder.- Overrides:
buildin classSimpleCommandBus.Builder- Returns:
- a
AsynchronousCommandBusas specified through this Builder
-