Package org.axonframework.queryhandling
Class SimpleQueryBus.Builder
java.lang.Object
org.axonframework.queryhandling.SimpleQueryBus.Builder
- Enclosing class:
SimpleQueryBus
Builder class to instantiate a
SimpleQueryBus.
The MessageMonitor is defaulted to NoOpMessageMonitor, TransactionManager to
NoTransactionManager, QueryInvocationErrorHandler to LoggingQueryInvocationErrorHandler,
the QueryUpdateEmitter to SimpleQueryUpdateEmitter and the QueryBusSpanFactory defaults
to a DefaultQueryBusSpanFactory backed by a NoOpSpanFactory.
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Initializes aSimpleQueryBusas specified through this Builder.duplicateQueryHandlerResolver(DuplicateQueryHandlerResolver duplicateQueryHandlerResolver) Sets the duplicate query handler resolver.errorHandler(QueryInvocationErrorHandler errorHandler) Sets theQueryInvocationErrorHandlerto handle exceptions during query handler invocation.messageMonitor(MessageMonitor<? super QueryMessage<?, ?>> messageMonitor) Sets theMessageMonitorused to monitor query messages.queryUpdateEmitter(QueryUpdateEmitter queryUpdateEmitter) Sets theQueryUpdateEmitterused to emits updates for theQueryBus.subscriptionQuery(SubscriptionQueryMessage).spanFactory(QueryBusSpanFactory spanFactory) Sets theQueryBusSpanFactoryimplementation to use for providing tracing capabilities.spanFactory(SpanFactory spanFactory) Deprecated.transactionManager(TransactionManager transactionManager) Sets theTransactionManagerused to manage the query handling transactions.protected voidvalidate()Validate whether the fields contained in this Builder are set accordingly.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
messageMonitor
public SimpleQueryBus.Builder messageMonitor(@Nonnull MessageMonitor<? super QueryMessage<?, ?>> messageMonitor) Sets theMessageMonitorused to monitor query messages. Defaults to aNoOpMessageMonitor.- Parameters:
messageMonitor- aMessageMonitorused to monitor query messages- Returns:
- the current Builder instance, for fluent interfacing
-
duplicateQueryHandlerResolver
public SimpleQueryBus.Builder duplicateQueryHandlerResolver(DuplicateQueryHandlerResolver duplicateQueryHandlerResolver) Sets the duplicate query handler resolver. This determines which registrations are added to the query bus when multiple handlers are detected for the same query.DuplicateQueryHandlerResolutioncontains good examples on this and will most of the time suffice. The bus defaults toDuplicateQueryHandlerResolution.logAndAccept().- Parameters:
duplicateQueryHandlerResolver- The invalid input: '{@link /*missing*/}' DuplicateQueryHandlerResolver to use when multiple registrations are detected- Returns:
- the current Builder instance, for fluent interfacing
-
transactionManager
Sets theTransactionManagerused to manage the query handling transactions. Defaults to aNoTransactionManager.- Parameters:
transactionManager- aTransactionManagerused to manage the query handling transactions- Returns:
- the current Builder instance, for fluent interfacing
-
errorHandler
Sets theQueryInvocationErrorHandlerto handle exceptions during query handler invocation. Defaults to aLoggingQueryInvocationErrorHandlerusing this instance it'sLogger.- Parameters:
errorHandler- aQueryInvocationErrorHandlerto handle exceptions during query handler invocation- Returns:
- the current Builder instance, for fluent interfacing
-
queryUpdateEmitter
Sets theQueryUpdateEmitterused to emits updates for theQueryBus.subscriptionQuery(SubscriptionQueryMessage). Defaults to aSimpleQueryUpdateEmitter.- Parameters:
queryUpdateEmitter- theQueryUpdateEmitterused to emits updates for theQueryBus.subscriptionQuery(SubscriptionQueryMessage)- Returns:
- the current Builder instance, for fluent interfacing
-
spanFactory
Deprecated.UsespanFactory(QueryBusSpanFactory)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 theQueryBusSpanFactoryimplementation to use for providing tracing capabilities. Defaults to aDefaultQueryBusSpanFactorybacked by aNoOpSpanFactoryby default, which provides no tracing capabilities.- Parameters:
spanFactory- TheQueryBusSpanFactoryimplementation.- Returns:
- The current Builder instance, for fluent interfacing.
-
build
Initializes aSimpleQueryBusas specified through this Builder.- Returns:
- a
SimpleQueryBusas specified through this Builder
-
validate
Validate whether the fields contained in this Builder are set accordingly.- Throws:
AxonConfigurationException- if one field is asserted to be incorrect according to the Builder's specifications
-
spanFactory(QueryBusSpanFactory)instead as it provides more configurability.