Class SimpleCommandBus.Builder
java.lang.Object
org.axonframework.commandhandling.SimpleCommandBus.Builder
- Direct Known Subclasses:
AsynchronousCommandBus.Builder
- Enclosing class:
SimpleCommandBus
Builder class to instantiate a
SimpleCommandBus.
The TransactionManager is defaulted to a NoTransactionManager, the MessageMonitor is
defaulted to a NoOpMessageMonitor, the RollbackConfiguration defaults to a
RollbackConfigurationType.UNCHECKED_EXCEPTIONS, the DuplicateCommandHandlerResolver defaults to
DuplicateCommandHandlerResolution.logAndOverride() and the CommandBusSpanFactory defaults to a
DefaultCommandBusSpanFactory with a NoOpSpanFactory.
The TransactionManager, MessageMonitor and RollbackConfiguration are hard
requirements. Thus setting them to null will result in an AxonConfigurationException.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Initializes aSimpleCommandBusas 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.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) Deprecated.transactionManager(TransactionManager transactionManager) Sets theTransactionManagerused to manage transactions.protected voidvalidate()Validate whether the fields contained in this Builder as set accordingly.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
transactionManager
Sets theTransactionManagerused to manage transactions. Defaults to aNoTransactionManager.- Parameters:
transactionManager- aTransactionManagerused to manage transactions- Returns:
- the current Builder instance, for fluent interfacing
-
messageMonitor
public SimpleCommandBus.Builder messageMonitor(@Nonnull MessageMonitor<? super CommandMessage<?>> messageMonitor) Sets theMessageMonitorof generic typeCommandMessageused the to monitor the command bus. Defaults to aNoOpMessageMonitor.- Parameters:
messageMonitor- aMessageMonitorused the message monitor to monitor the command bus- Returns:
- the current Builder instance, for fluent interfacing
-
rollbackConfiguration
public SimpleCommandBus.Builder rollbackConfiguration(@Nonnull RollbackConfiguration rollbackConfiguration) Sets theRollbackConfigurationwhich allows you to specify when aUnitOfWorkshould be rolled back. Defaults to aRollbackConfigurationType.UNCHECKED_EXCEPTIONS, which triggers a rollback on all unchecked exceptions.- Parameters:
rollbackConfiguration- aRollbackConfigurationspecifying when aUnitOfWorkshould be rolled back- Returns:
- the current Builder instance, for fluent interfacing
-
duplicateCommandHandlerResolver
public SimpleCommandBus.Builder duplicateCommandHandlerResolver(@Nonnull DuplicateCommandHandlerResolver duplicateCommandHandlerResolver) Sets theDuplicateCommandHandlerResolverused to resolves the road to take when a duplicate command handler is subscribed. Defaults toDuplicateCommandHandlerResolution.logAndOverride().- Parameters:
duplicateCommandHandlerResolver- aDuplicateCommandHandlerResolverused to resolves the road to take when a duplicate command handler is subscribed- Returns:
- the current Builder instance, for fluent interfacing
-
defaultCommandCallback
public SimpleCommandBus.Builder defaultCommandCallback(@Nonnull CommandCallback<Object, Object> defaultCommandCallback) Sets 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.- 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 byNoOpSpanFactoryby default, which provides no tracing capabilities.- Parameters:
spanFactory- TheCommandBusSpanFactoryimplementation.- Returns:
- The current Builder instance, for fluent interfacing.
-
build
Initializes aSimpleCommandBusas specified through this Builder.- Returns:
- a
SimpleCommandBusas 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.