Class EventProcessingConfigurer
EventProcessor types:
The EventProcessingConfigurer acts as a composite module that delegates event EventProcessorConfiguration to
specialized sub-modules: PooledStreamingEventProcessorsConfigurer for
PooledStreamingEventProcessor
instances and SubscribingEventProcessorsConfigurer for
SubscribingEventProcessor instances.
The main purpose is to provide shared configuration capabilities for all event processor types, allowing you to set
default configurations like UnitOfWorkFactory that apply to
all processors while still enabling type-specific customizations.
The module automatically configures default transaction management by registering a
TransactionalUnitOfWorkFactory when a TransactionManager is available in the configuration.
This module is automatically created and registered by the MessagingConfigurer
when the application starts, so you typically don't need to instantiate it manually. Instead, access it through
MessagingConfigurer.eventProcessing(java.util.function.Consumer).
Example usage:
MessagingConfigurer.create()
.eventProcessing(eventProcessing -> eventProcessing
.defaults(config -> config.unitOfWorkFactory(new SimpleUnitOfWorkFactory()))
.pooledStreaming(pooledStreaming ->
pooledStreaming.processor("calendar-processor", components -> components.declarative(cfg -> weekStartedEventHandler))
.processor("astrologers-week-symbol-processor", components -> components.declarative(cfg -> weekSymbolProclaimedEventHandler)))
.subscribing(subscribing ->
subscribing.processor("creatures-dwelling-readmodel", components -> components.autodetected(cfg -> dwellingBuiltEventHandler)));
- Since:
- 5.0.0
- Author:
- Mateusz Nowak
-
Constructor Summary
ConstructorsConstructorDescriptionConstructs a new event processing module with the given name. -
Method Summary
Modifier and TypeMethodDescriptionvoidbuild()Builds the configurer, registering the necessary modules and customizations.componentRegistry(Consumer<ComponentRegistry> componentRegistrar) Executes the givencomponentRegistraron the component registry associated with theMessagingConfigurer, which is the parent of this configurer.defaults(BiFunction<Configuration, EventProcessorConfiguration, EventProcessorConfiguration> configureDefaults) Configures default settings that will be applied to all event processors managed by this module.defaults(UnaryOperator<EventProcessorConfiguration> configureDefaults) Configures default settings that will be applied to all event processors managed by this module.pooledStreaming(UnaryOperator<PooledStreamingEventProcessorsConfigurer> processorsModuleTask) Provides access to configurePooledStreamingEventProcessorinstances through thePooledStreamingEventProcessorsConfigurer.subscribing(UnaryOperator<SubscribingEventProcessorsConfigurer> processorsModuleTask) Provides access to configureSubscribingEventProcessorinstances through theSubscribingEventProcessorsConfigurer.
-
Constructor Details
-
EventProcessingConfigurer
Constructs a new event processing module with the given name.This constructor is marked as
Internalbecause the module is automatically created and managed by theMessagingConfigurer. Typically, users should not instantiate this class directly but instead access it throughMessagingConfigurer.eventProcessing(java.util.function.Consumer).- Parameters:
parent- TheMessagingConfigurerto enhance with configuration of event processing components.
-
-
Method Details
-
build
public void build()Builds the configurer, registering the necessary modules and customizations.This method is typically called by the
MessagingConfigurerduring application startup to finalize the configuration of event processors. -
defaults
public EventProcessingConfigurer defaults(@Nonnull BiFunction<Configuration, EventProcessorConfiguration, EventProcessorConfiguration> configureDefaults) Configures default settings that will be applied to all event processors managed by this module.This method allows you to specify configurations that should be shared across both pooled streaming and subscribing event processors. The provided function receives both the Axon
Configurationand theEventProcessorConfiguration, allowing access to application-wide components when setting defaults.Common use cases include setting default
UnitOfWorkFactory, error handlers, or processing policies that should apply to all processors unless explicitly overridden.- Parameters:
configureDefaults- A function that receives the Axon configuration andEventProcessorConfiguration, returning a modifiedEventProcessorConfigurationwith the desired defaults applied.- Returns:
- This module instance for method chaining.
-
defaults
public EventProcessingConfigurer defaults(@Nonnull UnaryOperator<EventProcessorConfiguration> configureDefaults) Configures default settings that will be applied to all event processors managed by this module.This is a simplified version of
defaults(BiFunction)that provides only theEventProcessorConfigurationfor modification, without access to the AxonConfiguration. Use this when your default configurations don't require components from the applicationConfiguration.- Parameters:
configureDefaults- A function that modifies theEventProcessorConfigurationwith desired defaults.- Returns:
- This module instance for method chaining.
-
pooledStreaming
public EventProcessingConfigurer pooledStreaming(@Nonnull UnaryOperator<PooledStreamingEventProcessorsConfigurer> processorsModuleTask) Provides access to configurePooledStreamingEventProcessorinstances through thePooledStreamingEventProcessorsConfigurer.Use this method to define specific pooled streaming event processors, set their configurations, and register event handling components. The provided function receives the module for
PooledStreamingEventProcessors and can register individual processors or configure module-wide settings.- Parameters:
processorsModuleTask- A function that configures thePooledStreamingEventProcessorsConfigurer.- Returns:
- This module instance for method chaining.
-
subscribing
public EventProcessingConfigurer subscribing(@Nonnull UnaryOperator<SubscribingEventProcessorsConfigurer> processorsModuleTask) Provides access to configureSubscribingEventProcessorinstances through theSubscribingEventProcessorsConfigurer.Use this method to define specific subscribing event processors, set their configurations, and register event handling components. The provided function receives the module for
SubscribingEventProcessors and can register individual processors or configure module-wide settings.- Parameters:
processorsModuleTask- A function that configures theSubscribingEventProcessorsConfigurer.- Returns:
- This module instance for method chaining.
-
componentRegistry
public EventProcessingConfigurer componentRegistry(@Nonnull Consumer<ComponentRegistry> componentRegistrar) Executes the givencomponentRegistraron the component registry associated with theMessagingConfigurer, which is the parent of this configurer.- Parameters:
componentRegistrar- The actions to take on the component registry.- Returns:
- This
EventProcessingConfigurerfor a fluent API.
-