public class AsynchronousEventProcessingStrategy extends Object implements EventProcessingStrategy
EventProcessingStrategy that creates event processing tasks for asynchronous execution.
Clients can decide if events may be processed in sequence or in parallel using a SequencingPolicy.| Constructor and Description |
|---|
AsynchronousEventProcessingStrategy(Executor executor,
SequencingPolicy<? super EventMessage<?>> sequencingPolicy)
Initializes a new
AsynchronousEventProcessingStrategy that uses the given executor to execute
event processing tasks and sequencingPolicy that determines if an event may be processed in sequence or
in parallel. |
| Modifier and Type | Method and Description |
|---|---|
void |
handle(List<? extends EventMessage<?>> events,
Consumer<List<? extends EventMessage<?>>> processor)
Handle the given batch of
events. |
protected EventProcessorTask |
newProcessingScheduler(EventProcessorTask.ShutdownCallback shutDownCallback)
Creates a new scheduler instance that schedules tasks on the executor service for the managed EventListener.
|
protected void |
schedule(List<? extends EventMessage<?>> events,
Consumer<List<? extends EventMessage<?>>> processor)
Schedules this task for execution when all pre-conditions have been met.
|
public AsynchronousEventProcessingStrategy(Executor executor, SequencingPolicy<? super EventMessage<?>> sequencingPolicy)
AsynchronousEventProcessingStrategy that uses the given executor to execute
event processing tasks and sequencingPolicy that determines if an event may be processed in sequence or
in parallel.executor - the event processing job executorsequencingPolicy - the policy that determines if an event may be processed in sequence or in parallelpublic void handle(@Nonnull List<? extends EventMessage<?>> events, @Nonnull Consumer<List<? extends EventMessage<?>>> processor)
EventProcessingStrategyevents. Once the strategy decides it is opportune to process the events it
should pass them back to the given processor.
Note that the strategy may call back to the processor more than once for a single invocation of this method. Also note that a batch of events passed back to the processor may be made up of events from different batches.
handle in interface EventProcessingStrategyevents - Events to be processedprocessor - Callback method on the processor that carries out the actual processing of eventsprotected void schedule(List<? extends EventMessage<?>> events, Consumer<List<? extends EventMessage<?>>> processor)
events - The messages to schedule for processingprocessor - The component that will perform the actual processingprotected EventProcessorTask newProcessingScheduler(EventProcessorTask.ShutdownCallback shutDownCallback)
shutDownCallback - The callback that needs to be notified when the scheduler stops processing.Copyright © 2010–2023. All rights reserved.