Class TrackingEventProcessor.Builder
- Enclosing class:
TrackingEventProcessor
TrackingEventProcessor.
The RollbackConfigurationType defaults to a RollbackConfigurationType.ANY_THROWABLE, the
ErrorHandler is defaulted to a PropagatingErrorHandler, the MessageMonitor defaults to a
NoOpMessageMonitor, the EventProcessorSpanFactory defaults to a
DefaultEventProcessorSpanFactory backed by a NoOpSpanFactory and the
TrackingEventProcessorConfiguration to a
TrackingEventProcessorConfiguration.forSingleThreadedProcessing() call. The Event Processor name,
EventHandlerInvoker, StreamableMessageSource, TokenStore and TransactionManager
are
hard requirements and as such should be provided.
-
Field Summary
Fields inherited from class org.axonframework.eventhandling.AbstractEventProcessor.Builder
name -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionbuild()Initializes aTrackingEventProcessoras specified through this Builder.errorHandler(ErrorHandler errorHandler) Sets theErrorHandlerinvoked when anUnitOfWorkis rolled back during processing.eventHandlerInvoker(EventHandlerInvoker eventHandlerInvoker) Sets theEventHandlerInvokerwhich will handle all the individualEventMessages.messageMonitor(MessageMonitor<? super EventMessage<?>> messageMonitor) Sets theMessageMonitorto monitorEventMessages before and after they're processed.messageSource(StreamableMessageSource<TrackedEventMessage<?>> messageSource) Sets thenameof thisEventProcessorimplementation.rollbackConfiguration(RollbackConfiguration rollbackConfiguration) Sets theRollbackConfigurationspecifying the rollback behavior of theUnitOfWorkwhile processing a batch of events.spanFactory(EventProcessorSpanFactory spanFactory) Sets theEventProcessorSpanFactoryimplementation to use for providing tracing capabilities.spanFactory(SpanFactory spanFactory) Deprecated.Set this processor to store Tracking Tokens only at the end of processing.tokenStore(TokenStore tokenStore) Sets theTokenStoreused to store and fetch event tokens that enable thisEventProcessorto track its progress.trackingEventProcessorConfiguration(TrackingEventProcessorConfiguration trackingEventProcessorConfiguration) Sets theTrackingEventProcessorConfigurationcontaining the fine grained configuration options for aTrackingEventProcessor.transactionManager(TransactionManager transactionManager) Sets theTransactionManagerused when processingEventMessages.protected voidvalidate()Validates whether the fields contained in this Builder are set accordingly.
-
Constructor Details
-
Builder
public Builder()
-
-
Method Details
-
name
Description copied from class:AbstractEventProcessor.BuilderSets thenameof thisEventProcessorimplementation.- Overrides:
namein classAbstractEventProcessor.Builder- Parameters:
name- aStringdefining thisEventProcessorimplementation- Returns:
- the current Builder instance, for fluent interfacing
-
eventHandlerInvoker
public TrackingEventProcessor.Builder eventHandlerInvoker(@Nonnull EventHandlerInvoker eventHandlerInvoker) Description copied from class:AbstractEventProcessor.BuilderSets theEventHandlerInvokerwhich will handle all the individualEventMessages.- Overrides:
eventHandlerInvokerin classAbstractEventProcessor.Builder- Parameters:
eventHandlerInvoker- theEventHandlerInvokerwhich will handle all the individualEventMessages- Returns:
- the current Builder instance, for fluent interfacing
-
rollbackConfiguration
public TrackingEventProcessor.Builder rollbackConfiguration(@Nonnull RollbackConfiguration rollbackConfiguration) Sets theRollbackConfigurationspecifying the rollback behavior of theUnitOfWorkwhile processing a batch of events.. Defaults to aRollbackConfigurationType.ANY_THROWABLE)- Overrides:
rollbackConfigurationin classAbstractEventProcessor.Builder- Parameters:
rollbackConfiguration- theRollbackConfigurationspecifying the rollback behavior of theUnitOfWorkwhile processing a batch of events.- Returns:
- the current Builder instance, for fluent interfacing
-
errorHandler
Description copied from class:AbstractEventProcessor.BuilderSets theErrorHandlerinvoked when anUnitOfWorkis rolled back during processing. Defaults to aPropagatingErrorHandler.- Overrides:
errorHandlerin classAbstractEventProcessor.Builder- Parameters:
errorHandler- theErrorHandlerinvoked when anUnitOfWorkis rolled back during processing- Returns:
- the current Builder instance, for fluent interfacing
-
messageMonitor
public TrackingEventProcessor.Builder messageMonitor(@Nonnull MessageMonitor<? super EventMessage<?>> messageMonitor) Description copied from class:AbstractEventProcessor.BuilderSets theMessageMonitorto monitorEventMessages before and after they're processed. Defaults to aNoOpMessageMonitor.- Overrides:
messageMonitorin classAbstractEventProcessor.Builder- Parameters:
messageMonitor- aMessageMonitorto monitorEventMessages before and after they're processed- Returns:
- the current Builder instance, for fluent interfacing
-
spanFactory
Description copied from class:AbstractEventProcessor.BuilderSets theEventProcessorSpanFactoryimplementation to use for providing tracing capabilities. Defaults to aDefaultEventProcessorSpanFactorybacked by aNoOpSpanFactoryby default, which provides no tracing capabilities.- Overrides:
spanFactoryin classAbstractEventProcessor.Builder- Parameters:
spanFactory- TheSpanFactoryimplementation- Returns:
- The current Builder instance, for fluent interfacing.
-
spanFactory
Deprecated.Description copied from class:AbstractEventProcessor.BuilderSets theSpanFactoryimplementation to use for providing tracing capabilities. Defaults to aNoOpSpanFactoryby default, which provides no tracing capabilities.- Overrides:
spanFactoryin classAbstractEventProcessor.Builder- Parameters:
spanFactory- TheSpanFactoryimplementation- Returns:
- The current Builder instance, for fluent interfacing.
-
messageSource
public TrackingEventProcessor.Builder messageSource(StreamableMessageSource<TrackedEventMessage<?>> messageSource) - Parameters:
messageSource- theStreamableMessageSource(e.g. theEventBus) which thisEventProcessorwill track- Returns:
- the current Builder instance, for fluent interfacing
-
tokenStore
Sets theTokenStoreused to store and fetch event tokens that enable thisEventProcessorto track its progress.- Parameters:
tokenStore- theTokenStoreused to store and fetch event tokens that enable thisEventProcessorto track its progress- Returns:
- the current Builder instance, for fluent interfacing
-
transactionManager
Sets theTransactionManagerused when processingEventMessages. Note that setting this value influences the behavior for storing tokens either at the start or at the end of a batch. If a TransactionManager other than aNoTransactionManageris configured, the default behavior is to store the last token of the Batch to the Token Store before processing of events begins. If theNoTransactionManageris provided, the default is to extend the claim at the start of the unit of work, and update the token after processing Events. When tokens are stored at the start of a batch, a claim extension will be sent at the end of the batch if processing that batch took longer than thetokenClaimUpdateInterval.Use
storingTokensAfterProcessing()to force storage of tokens at the end of a batch.- Parameters:
transactionManager- theTransactionManagerused when processingEventMessages- Returns:
- the current Builder instance, for fluent interfacing
- See Also:
-
trackingEventProcessorConfiguration
public TrackingEventProcessor.Builder trackingEventProcessorConfiguration(TrackingEventProcessorConfiguration trackingEventProcessorConfiguration) Sets theTrackingEventProcessorConfigurationcontaining the fine grained configuration options for aTrackingEventProcessor. Defaults to aTrackingEventProcessorConfiguration.forSingleThreadedProcessing()call.- Parameters:
trackingEventProcessorConfiguration- theTrackingEventProcessorConfigurationcontaining the fine grained configuration options for aTrackingEventProcessor- Returns:
- the current Builder instance, for fluent interfacing
-
storingTokensAfterProcessing
Set this processor to store Tracking Tokens only at the end of processing. This has an impact on performance, as the processor will need to extend the claim at the start of the process, and then update the token at the end. This causes 2 round-trips to the Token Store per batch of events.Enable this when a Token Store cannot participate in a transaction, or when at-most-once-delivery semantics are desired.
The default behavior is to store the last token of the Batch to the Token Store before processing of events begins, if a TransactionManager is configured. If the
NoTransactionManageris provided, the default is to extend the claim at the start of the unit of work, and update the token after processing Events. When tokens are stored at the start of a batch, a claim extension will be sent at the end of the batch if processing that batch took longer than thetokenClaimUpdateInterval.- Returns:
- the current Builder instance, for fluent interfacing
-
build
Initializes aTrackingEventProcessoras specified through this Builder.- Returns:
- a
TrackingEventProcessoras specified through this Builder
-
validate
Validates whether the fields contained in this Builder are set accordingly.- Overrides:
validatein classAbstractEventProcessor.Builder- Throws:
AxonConfigurationException- if one field is asserted to be incorrect according to the Builder's specifications
-