public class EventHandlingConfiguration extends Object implements ModuleConfiguration
Modifier and Type | Class and Description |
---|---|
static interface |
EventHandlingConfiguration.EventProcessorBuilder
Deprecated.
|
Constructor and Description |
---|
EventHandlingConfiguration()
Creates a default configuration for an Event Handling module that creates a
SubscribingEventProcessor
instance for all Event Handlers that have the same Processing Group name. |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
phase, unwrap
public EventHandlingConfiguration()
SubscribingEventProcessor
instance for all Event Handlers that have the same Processing Group name. The Processing Group name is determined
by inspecting the ProcessingGroup
annotation; if no annotation is present, the package name is used as
the Processing Group name. This default behavior can be overridden in the instance returned.
At a minimum, the Event Handler beans need to be registered before this component is useful.
@Deprecated public List<MessageHandlerInterceptor<? super EventMessage<?>>> interceptorsFor(Configuration configuration, String processorName)
EventProcessingConfiguration.interceptorsFor(String)
insteadprocessorName
.configuration
- The main configurationprocessorName
- The name of the processor to retrieve interceptors forregisterHandlerInterceptor(BiFunction)
,
registerHandlerInterceptor(String, Function)
@Deprecated public EventHandlingConfiguration usingTrackingProcessors()
EventProcessingConfiguration.usingTrackingProcessors()
instead
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).
@Deprecated public EventHandlingConfiguration usingTrackingProcessors(Function<Configuration,TrackingEventProcessorConfiguration> config, Function<Configuration,SequencingPolicy<? super EventMessage<?>>> sequencingPolicy)
EventProcessingConfiguration.usingTrackingProcessors(Function)
instead
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.
config
- The configuration for the processors to usesequencingPolicy
- The policy for processing events sequentially@Deprecated public EventHandlingConfiguration registerTrackingProcessor(String name)
EventProcessingConfiguration.registerTrackingEventProcessor(String)
insteadname
. 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 processor@Deprecated public EventHandlingConfiguration registerTrackingProcessor(String name, Function<Configuration,StreamableMessageSource<TrackedEventMessage<?>>> source)
EventProcessingConfiguration.registerTrackingEventProcessorUsingSource(String, Function)
insteadsource
to read messages from.name
- The name of the TrackingProcessorsource
- The source of messages for this processor@Deprecated public EventHandlingConfiguration registerTrackingProcessor(String name, Function<Configuration,TrackingEventProcessorConfiguration> processorConfiguration, Function<Configuration,SequencingPolicy<? super EventMessage<?>>> sequencingPolicy)
EventProcessingConfiguration.registerTrackingEventProcessor(String, Function)
insteadname
, reading from the Event Bus (or Store) from the main
configuration and using the given processorConfiguration
. The given sequencingPolicy
defines
the policy for events that need to be executed sequentially.name
- The name of the Tracking ProcessorprocessorConfiguration
- The configuration for the processorsequencingPolicy
- The sequencing policy to apply when processing events in parallel@Deprecated public EventHandlingConfiguration registerTrackingProcessor(String name, Function<Configuration,StreamableMessageSource<TrackedEventMessage<?>>> source, Function<Configuration,TrackingEventProcessorConfiguration> processorConfiguration, Function<Configuration,SequencingPolicy<? super EventMessage<?>>> sequencingPolicy)
EventProcessingConfiguration.registerTrackingEventProcessor(String, Function, Function)
insteadname
, reading from the given source
and using the
given processorConfiguration
. The given sequencingPolicy
defines the policy for events that need
to be executed sequentially.name
- The name of the Tracking Processorsource
- The source to read Events fromprocessorConfiguration
- The configuration for the processorsequencingPolicy
- The sequencing policy to apply when processing events in parallel@Deprecated public EventHandlingConfiguration registerEventProcessorFactory(EventHandlingConfiguration.EventProcessorBuilder eventProcessorBuilder)
EventProcessingConfiguration.registerEventProcessorFactory(EventProcessingConfiguration.EventProcessorBuilder)
instead
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 Processor@Deprecated public EventHandlingConfiguration registerEventProcessor(String name, EventHandlingConfiguration.EventProcessorBuilder eventProcessorBuilder)
EventProcessingConfiguration.registerEventProcessor(String,
EventProcessingConfiguration.EventProcessorBuilder)
insteadname
. 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 Processor@Deprecated public EventHandlingConfiguration registerHandlerInterceptor(String processorName, Function<Configuration,MessageHandlerInterceptor<? super EventMessage<?>>> interceptorBuilder)
EventProcessingConfiguration.registerHandlerInterceptor(String, Function)
insteadinterceptorBuilder
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.
Note that a CorrelationDataInterceptor is registered by default. To change correlation data attached to messages,
see Configurer.configureCorrelationDataProviders(Function)
.
processorName
- The name of the processor to register the interceptor oninterceptorBuilder
- The function providing the interceptor to register, or null
@Deprecated public EventHandlingConfiguration registerHandlerInterceptor(BiFunction<Configuration,String,MessageHandlerInterceptor<? super EventMessage<?>>> interceptorBuilder)
EventProcessingConfiguration.registerHandlerInterceptor(String, Function)
insteadinterceptorBuilder
to build an Message Handling Interceptor for Event Processors
created in this configuration.
The interceptorBuilder
is invoked once for each processor created, and may return null
, in which
case the return value is ignored.
Note that a CorrelationDataInterceptor is registered by default. To change correlation data attached to messages,
see Configurer.configureCorrelationDataProviders(Function)
.
interceptorBuilder
- The builder function that provides an interceptor for each available processorpublic EventHandlingConfiguration byDefaultAssignTo(String name)
ProcessingGroup
annotation is found.name
- The Event Processor name to assign Event Handlers topublic EventHandlingConfiguration byDefaultAssignTo(Function<Object,String> assignmentFunction)
ProcessingGroup
annotation is found.assignmentFunction
- The function that returns the Processing Group for each Event Handler beanpublic EventHandlingConfiguration assignHandlersMatching(String name, Predicate<Object> criteria)
criteria
to the Event Processor
with given name
, with neutral priority (value 0).
Note that, when beans match multiple criteria for different processors with equal priority, the outcome is undefined.
name
- The name of the Event Processor to assign matching Event Handlers tocriteria
- The criteria for Event Handler to matchpublic EventHandlingConfiguration assignHandlersMatching(String name, int priority, Predicate<Object> criteria)
criteria
to the Event Processor
with given name
, with given priority
. Rules with higher value of priority
take precedence
over those with a lower value.
Note that, when beans match multiple criteria for different processors with equal priority, the outcome is undefined.
name
- The name of the Event Processor to assign matching Event Handlers topriority
- The priority for this rulecriteria
- The criteria for Event Handler to matchpublic EventHandlingConfiguration registerSequencingPolicy(String name, Function<Configuration,SequencingPolicy<? super EventMessage<?>>> policyBuilder)
policyBuilder
to the processing group with given
name
. Any previously configured policy for the same name will be overwritten.name
- The name of the processing group to assign the sequencing policy forpolicyBuilder
- The builder function to create the policy to usepublic EventHandlingConfiguration registerDefaultSequencingPolicy(Function<Configuration,SequencingPolicy<? super EventMessage<?>>> policyBuilder)
policyBuilder
to the processing groups for which no
explicit policy is defined (using registerSequencingPolicy(String, Function)
).
Defaults to a SequentialPerAggregatePolicy
.
policyBuilder
- The builder function to create the policy to usepublic EventHandlingConfiguration registerEventHandler(Function<Configuration,Object> eventHandlerBuilder)
eventHandlerBuilder
- The builder function for the Event Handler beanpublic 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()
@Deprecated public EventHandlingConfiguration registerSubscribingEventProcessor(String name)
EventProcessingConfiguration.registerSubscribingEventProcessor(String)
insteadname
that subscribes to the Event Bus.name
- The name of the Event Processor@Deprecated public EventHandlingConfiguration registerSubscribingEventProcessor(String name, Function<Configuration,SubscribableMessageSource<? extends EventMessage<?>>> messageSource)
EventProcessingConfiguration.registerSubscribingEventProcessor(String, Function)
insteadname
that subscribes to the given messageSource
.
This allows the use of standard Subscribing Processors that listen to another source than the Event Bus.name
- The name of the Event ProcessormessageSource
- The source the processor should read from@Deprecated public EventHandlingConfiguration registerTokenStore(String name, Function<Configuration,TokenStore> tokenStore)
EventProcessingConfiguration.registerTokenStore(String, Function)
insteadname
.
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 Configuration@Deprecated public List<EventProcessor> getProcessors()
EventProcessingConfiguration.eventProcessors()
insteadinitialized
yet.@Deprecated public <T extends EventProcessor> Optional<T> getProcessor(String name)
EventProcessingConfiguration.eventProcessor(String)
insteadname
, if present. This method also returns an unresolved
optional if the Processor was configured, but it hasn't been assigned any Event Handlers.name
- The name of the processor to return@Deprecated public <T extends EventProcessor> Optional<T> getProcessor(String name, Class<T> expectedType)
EventProcessingConfiguration.eventProcessor(String, Class)
insteadname
, if present and of the given expectedType
. This
method also returns an empty optional if the Processor was configured, but it hasn't been assigned any Event
Handlers.T
- The type of processor expectedname
- The name of the processor to returnexpectedType
- The type of processor expectedpublic EventHandlingConfiguration configureListenerInvocationErrorHandler(Function<Configuration,ListenerInvocationErrorHandler> listenerInvocationErrorHandlerBuilder)
ListenerInvocationErrorHandler
for any
EventProcessor
. This can be overridden per EventProcessor by calling the
configureListenerInvocationErrorHandler(String, Function)
function.listenerInvocationErrorHandlerBuilder
- The ListenerInvocationErrorHandler
to use for the EventProcessor
with the given name
EventHandlingConfiguration
instance for further configurationpublic EventHandlingConfiguration configureListenerInvocationErrorHandler(String name, Function<Configuration,ListenerInvocationErrorHandler> listenerInvocationErrorHandlerBuilder)
ListenerInvocationErrorHandler
for the
EventProcessor
of the given name
. This overrides the default
ListenerInvocationErrorHandler configured through the Configurer
.name
- The name of the event processorlistenerInvocationErrorHandlerBuilder
- The ListenerInvocationErrorHandler
to use for the EventProcessor
with the given name
EventHandlingConfiguration
instance for further configuration@Deprecated public EventHandlingConfiguration configureMessageMonitor(String name, Function<Configuration,MessageMonitor<Message<?>>> messageMonitorBuilder)
EventProcessingConfiguration.configureMessageMonitor(String, Function)
insteadEventProcessor
of the given name.
This overrides any Message Monitor configured through Configurer
.name
- The name of the event processormessageMonitorBuilder
- The builder function to use@Deprecated public EventHandlingConfiguration configureMessageMonitor(String name, MessageMonitorFactory messageMonitorFactory)
EventProcessingConfiguration.configureMessageMonitor(String, MessageMonitorFactory)
insteadEventProcessor
of the given name. This
overrides any Message Monitor configured through Configurer
.name
- The name of the event processormessageMonitorFactory
- The factory to use@Deprecated public EventHandlingConfiguration configureErrorHandler(Function<Configuration,ErrorHandler> errorHandlerBuilder)
EventProcessingConfiguration.configureErrorHandler(Function)
insteadErrorHandler
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
EventHandlingConfiguration
instance for further configuration@Deprecated public EventHandlingConfiguration configureErrorHandler(String name, Function<Configuration,ErrorHandler> errorHandlerBuilder)
EventProcessingConfiguration.configureErrorHandler(String, Function)
insteadErrorHandler
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
EventHandlingConfiguration
instance for further configurationCopyright © 2010–2018. All rights reserved.