public class EventProcessingConfiguration extends Object implements ModuleConfiguration
EventProcessor
s and EventHandlerInvoker
s and all necessary information in order to tie those two together. After calling initialize(Configuration)
, all registrations (except for MessageHandlerInterceptor
s) are ignored.Modifier and Type | Class and Description |
---|---|
static interface |
EventProcessingConfiguration.EventProcessorBuilder
Contract which defines how to build an event processor.
|
Constructor and Description |
---|
EventProcessingConfiguration() |
Modifier and Type | Method and Description |
---|---|
EventProcessingConfiguration |
assignProcessingGroup(Function<String,String> assignmentRule)
Defines a rule for assigning processing groups to processors if processing group to processor name mapping does
not contain the entry.
|
EventProcessingConfiguration |
assignProcessingGroup(String processingGroup,
String processorName)
Defines a mapping for assigning processing groups to processors.
|
EventProcessingConfiguration |
configureErrorHandler(Function<Configuration,ErrorHandler> errorHandlerBuilder)
Configures the default
ErrorHandler for any
EventProcessor . |
EventProcessingConfiguration |
configureErrorHandler(String name,
Function<Configuration,ErrorHandler> errorHandlerBuilder)
|
EventProcessingConfiguration |
configureMessageMonitor(String name,
Function<Configuration,MessageMonitor<Message<?>>> messageMonitorBuilder)
Configures the builder function to create the Message Monitor for the
EventProcessor of the given name. |
EventProcessingConfiguration |
configureMessageMonitor(String name,
MessageMonitorFactory messageMonitorFactory)
Configures the factory to create the Message Monitor for the
EventProcessor of the given name. |
EventProcessingConfiguration |
configureRollbackConfiguration(String name,
Function<Configuration,RollbackConfiguration> rollbackConfigurationBuilder)
|
EventProcessingConfiguration |
configureTransactionManager(String name,
Function<Configuration,TransactionManager> transactionManagerBuilder)
|
<T extends EventProcessor> |
eventProcessor(String name)
Obtains Event Processor by name.
|
<T extends EventProcessor> |
eventProcessor(String name,
Class<T> expectedType)
Returns the Event Processor with the given
name , if present and of the given expectedType . |
<T extends EventProcessor> |
eventProcessorByProcessingGroup(String processingGroup)
Obtains Event Processor by processing group name.
|
<T extends EventProcessor> |
eventProcessorByProcessingGroup(String processingGroup,
Class<T> expectedType)
Returns the Event Processor by the given
processingGroup , if present and of the given expectedType . |
Map<String,EventProcessor> |
eventProcessors()
Obtains all registered event processors.
|
void |
initialize(Configuration config)
Initialize the module configuration using the given global
config |
List<MessageHandlerInterceptor<? super EventMessage<?>>> |
interceptorsFor(String processorName)
Returns a list of interceptors for a processor with given
processorName . |
int |
phase()
Defines a phase in which this module's
ModuleConfiguration.initialize(Configuration) , ModuleConfiguration.start() , ModuleConfiguration.shutdown()
will be invoked. |
EventProcessingConfiguration |
registerEventProcessor(String name,
EventProcessingConfiguration.EventProcessorBuilder eventProcessorBuilder)
Defines the Event Processor builder for an Event Processor with the given
name . |
EventProcessingConfiguration |
registerEventProcessorFactory(EventProcessingConfiguration.EventProcessorBuilder eventProcessorBuilder)
Allows for more fine-grained definition of the Event Processor to use for each group of Event Listeners.
|
EventProcessingConfiguration |
registerHandlerInterceptor(String processorName,
Function<Configuration,MessageHandlerInterceptor<? super EventMessage<?>>> interceptorBuilder)
Register the given
interceptorBuilder to build an Message Handling Interceptor for the Event Processor
with given processorName . |
EventProcessingConfiguration |
registerHandlerInvoker(String processingGroup,
Function<Configuration,EventHandlerInvoker> eventHandlerInvokerBuilder)
Registers handler invoker within this registry which will be assigned to the event processing group with given
processingGroup during the initialization phase. |
EventProcessingConfiguration |
registerSubscribingEventProcessor(String name)
Register a subscribing event processor with given
name that subscribes to the Event Bus. |
EventProcessingConfiguration |
registerSubscribingEventProcessor(String name,
Function<Configuration,SubscribableMessageSource<? extends EventMessage<?>>> messageSource)
Register a subscribing event processor with given
name that subscribes to the given messageSource . |
EventProcessingConfiguration |
registerTokenStore(String name,
Function<Configuration,TokenStore> tokenStore)
Register the TokenStore to use for a processor of given
name . |
EventProcessingConfiguration |
registerTrackingEventProcessor(String name)
Register a TrackingEventProcessor using default configuration for the given
name . |
EventProcessingConfiguration |
registerTrackingEventProcessor(String name,
Function<Configuration,StreamableMessageSource<TrackedEventMessage<?>>> source,
Function<Configuration,TrackingEventProcessorConfiguration> processorConfiguration)
Registers a TrackingEventProcessor with the given
name , reading from the given source and using
the given processorConfiguration . |
EventProcessingConfiguration |
registerTrackingEventProcessor(String name,
Function<Configuration,TrackingEventProcessorConfiguration> processorConfiguration)
Registers a TrackingEventProcessor with the given
name , reading from the Event Bus (or Store) from the
main configuration and using the given processorConfiguration . |
EventProcessingConfiguration |
registerTrackingEventProcessorUsingSource(String name,
Function<Configuration,StreamableMessageSource<TrackedEventMessage<?>>> source)
Registers a TrackingEventProcessor using the given
source to read messages from. |
void |
shutdown()
Invoked prior to shutdown of the application.
|
void |
start()
Invoked when the Configuration is started.
|
EventProcessingConfiguration |
usingTrackingProcessors()
Configure the use of Tracking Event Processors, instead of the default Subscribing ones.
|
EventProcessingConfiguration |
usingTrackingProcessors(Function<Configuration,TrackingEventProcessorConfiguration> processorConfig)
Configure the use of Tracking Event Processors, instead of the default Subscribing ones.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
unwrap
public EventProcessingConfiguration registerHandlerInvoker(String processingGroup, Function<Configuration,EventHandlerInvoker> eventHandlerInvokerBuilder)
processingGroup
during the initialization phase.processingGroup
- The name of the Processing GroupeventHandlerInvokerBuilder
- Builder which builds event handler invoker. Builder can use configuration to
obtain other componentspublic EventProcessingConfiguration assignProcessingGroup(String processingGroup, String processorName)
processingGroup
- The processing group to be assignedprocessorName
- The processor name to assign group topublic EventProcessingConfiguration assignProcessingGroup(Function<String,String> assignmentRule)
assignmentRule
- The function which takes processing group and returns processor nameassignProcessingGroup(String, String)
public EventProcessingConfiguration registerEventProcessor(String name, EventProcessingConfiguration.EventProcessorBuilder eventProcessorBuilder)
name
. Event Processors
registered using this method have priority over those defined in
registerEventProcessorFactory(EventProcessorBuilder)
.
The given builder is expected to create a fully initialized Event Processor implementation based on the name and list of event handler beans. The builder also received the global configuration instance, from which it can retrieve components.
Note that the processor must be initialized, but shouldn't be started yet. The processor's
EventProcessor.start()
method is invoked when the global configuration is started.
name
- The name of the Event Processor for which to use this buildereventProcessorBuilder
- The builder function for the Event Processorpublic EventProcessingConfiguration registerTrackingEventProcessor(String name)
name
. Unlike
usingTrackingProcessors()
, this method will not default all processors to tracking, but instead only
use tracking for event handler that have been assigned to the processor with given name
.
Events will be read from the EventBus (or EventStore) registered with the main configuration
name
- The name of the processorpublic EventProcessingConfiguration registerTrackingEventProcessorUsingSource(String name, Function<Configuration,StreamableMessageSource<TrackedEventMessage<?>>> source)
source
to read messages from.name
- The name of the TrackingEventProcessorsource
- The source of messages for this processorpublic EventProcessingConfiguration registerTrackingEventProcessor(String name, Function<Configuration,TrackingEventProcessorConfiguration> processorConfiguration)
name
, reading from the Event Bus (or Store) from the
main configuration and using the given processorConfiguration
.name
- The name of the Tracking ProcessorprocessorConfiguration
- The configuration for the processorpublic EventProcessingConfiguration registerTrackingEventProcessor(String name, Function<Configuration,StreamableMessageSource<TrackedEventMessage<?>>> source, Function<Configuration,TrackingEventProcessorConfiguration> processorConfiguration)
name
, reading from the given source
and using
the given processorConfiguration
.name
- The name of the Tracking Processorsource
- The source to read Events fromprocessorConfiguration
- The configuration for the processorpublic EventProcessingConfiguration registerSubscribingEventProcessor(String name)
name
that subscribes to the Event Bus.name
- The name of the Event Processorpublic EventProcessingConfiguration registerSubscribingEventProcessor(String name, Function<Configuration,SubscribableMessageSource<? extends EventMessage<?>>> messageSource)
name
that subscribes to the given messageSource
. This allows the use of standard Subscribing Event Processors that listen to another source than
the Event Bus.name
- The name of the Event ProcessormessageSource
- The source the processor should read frompublic EventProcessingConfiguration usingTrackingProcessors()
The processor will use the TokenStore
implementation provided in the global Configuration, and will
default to an InMemoryTokenStore
when no Token Store was defined. Note that it is not recommended to use
the in-memory TokenStore in a production environment.
The processors will use the a TrackingEventProcessorConfiguration
registered with the configuration, or
otherwise to a single threaded configuration (which means the processor will run in a single Thread and a batch
size of 1).
public EventProcessingConfiguration usingTrackingProcessors(Function<Configuration,TrackingEventProcessorConfiguration> processorConfig)
The processor will use the TokenStore
implementation provided in the global Configuration, and will
default to an InMemoryTokenStore
when no Token Store was defined. Note that it is not recommended to use
the in-memory TokenStore in a production environment.
processorConfig
- The configuration for the processors to usepublic EventProcessingConfiguration registerTokenStore(String name, Function<Configuration,TokenStore> tokenStore)
name
.
If no explicit TokenStore implementation is available for a Processor, it is taken from the main Configuration.
Note that this configuration is ignored if the processor with given name isn't a Tracking Processor.
name
- The name of the processor to configure the token store fortokenStore
- The function providing the TokenStore based on a given Configurationpublic EventProcessingConfiguration registerHandlerInterceptor(String processorName, Function<Configuration,MessageHandlerInterceptor<? super EventMessage<?>>> interceptorBuilder)
interceptorBuilder
to build an Message Handling Interceptor for the Event Processor
with given processorName
.
The interceptorBuilder
may return null
, in which case the return value is ignored.
processorName
- The name of the processor to register the interceptor oninterceptorBuilder
- The function providing the interceptor to register, or null
public List<MessageHandlerInterceptor<? super EventMessage<?>>> interceptorsFor(String processorName)
processorName
.processorName
- The name of the processorprocessorName
public EventProcessingConfiguration registerEventProcessorFactory(EventProcessingConfiguration.EventProcessorBuilder eventProcessorBuilder)
Note that the processor must be initialized, but shouldn't be started yet. The processor's
EventProcessor.start()
method is invoked when the global configuration is started.
eventProcessorBuilder
- The builder function for the Event Processorpublic EventProcessingConfiguration configureErrorHandler(Function<Configuration,ErrorHandler> errorHandlerBuilder)
ErrorHandler
for any
EventProcessor
. This can be overridden per EventProcessor by calling the
configureErrorHandler(String, Function)
function.errorHandlerBuilder
- The ErrorHandler
to use for the
EventProcessor
with the given name
public EventProcessingConfiguration configureErrorHandler(String name, Function<Configuration,ErrorHandler> errorHandlerBuilder)
ErrorHandler
for the
EventProcessor
of the given name
. This
overrides the default ErrorHandler configured through the Configurer
.name
- The name of the event processorerrorHandlerBuilder
- The ErrorHandler
to use for the
EventProcessor
with the given name
public EventProcessingConfiguration configureRollbackConfiguration(String name, Function<Configuration,RollbackConfiguration> rollbackConfigurationBuilder)
RollbackConfiguration
for the EventProcessor
of the given name
. This
overrides the default RollbackConfiguration configured through the Configurer
.name
- The name of the event processorrollbackConfigurationBuilder
- The RollbackConfiguration
to use for the EventProcessor
with
the given name
public EventProcessingConfiguration configureTransactionManager(String name, Function<Configuration,TransactionManager> transactionManagerBuilder)
TransactionManager
for the EventProcessor
of the given name
. This overrides
the default TransactionManager configured through the Configurer
.name
- The name of the event processortransactionManagerBuilder
- The TransactionManager
to use of the EventProcessor
with the
given name
public EventProcessingConfiguration configureMessageMonitor(String name, Function<Configuration,MessageMonitor<Message<?>>> messageMonitorBuilder)
EventProcessor
of the given name.
This overrides any Message Monitor configured through Configurer
.name
- The name of the event processormessageMonitorBuilder
- The builder function to usepublic EventProcessingConfiguration configureMessageMonitor(String name, MessageMonitorFactory messageMonitorFactory)
EventProcessor
of the given name. This
overrides any Message Monitor configured through Configurer
.name
- The name of the event processormessageMonitorFactory
- The factory to usepublic Map<String,EventProcessor> eventProcessors()
public <T extends EventProcessor> Optional<T> eventProcessor(String name)
T
- The type of processor expectedname
- The name of the event processorpublic <T extends EventProcessor> Optional<T> eventProcessor(String name, Class<T> expectedType)
name
, if present and of the given expectedType
.T
- The type of processor expectedname
- The name of the processor to returnexpectedType
- The type of processor expectedpublic <T extends EventProcessor> Optional<T> eventProcessorByProcessingGroup(String processingGroup)
T
- The type of processor expectedprocessingGroup
- The name of the processing grouppublic <T extends EventProcessor> Optional<T> eventProcessorByProcessingGroup(String processingGroup, Class<T> expectedType)
processingGroup
, if present and of the given expectedType
.T
- The type of processor expectedprocessingGroup
- The name of the processing groupexpectedType
- The type of processor expectedpublic int phase()
ModuleConfiguration
ModuleConfiguration.initialize(Configuration)
, ModuleConfiguration.start()
, ModuleConfiguration.shutdown()
will be invoked.phase
in interface ModuleConfiguration
public void initialize(Configuration config)
ModuleConfiguration
config
initialize
in interface ModuleConfiguration
config
- the global configuration, providing access to generic componentspublic void start()
ModuleConfiguration
start
in interface ModuleConfiguration
Configuration.start()
public void shutdown()
ModuleConfiguration
shutdown
in interface ModuleConfiguration
Configuration.shutdown()
Copyright © 2010–2018. All rights reserved.