Class AsynchronousEventProcessingStrategy
java.lang.Object
org.axonframework.eventhandling.async.AsynchronousEventProcessingStrategy
- All Implemented Interfaces:
EventProcessingStrategy
Implementation of a
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.- Author:
- Rene de Waele
-
Constructor Summary
ConstructorsConstructorDescriptionAsynchronousEventProcessingStrategy(Executor executor, SequencingPolicy<? super EventMessage<?>> sequencingPolicy) Initializes a newAsynchronousEventProcessingStrategythat uses the givenexecutorto execute event processing tasks andsequencingPolicythat determines if an event may be processed in sequence or in parallel. -
Method Summary
Modifier and TypeMethodDescriptionvoidhandle(List<? extends EventMessage<?>> events, Consumer<List<? extends EventMessage<?>>> processor) Handle the given batch ofevents.protected EventProcessorTasknewProcessingScheduler(EventProcessorTask.ShutdownCallback shutDownCallback) Creates a new scheduler instance that schedules tasks on the executor service for the managed EventListener.protected voidschedule(List<? extends EventMessage<?>> events, Consumer<List<? extends EventMessage<?>>> processor) Schedules this task for execution when all pre-conditions have been met.
-
Constructor Details
-
AsynchronousEventProcessingStrategy
public AsynchronousEventProcessingStrategy(Executor executor, SequencingPolicy<? super EventMessage<?>> sequencingPolicy) Initializes a newAsynchronousEventProcessingStrategythat uses the givenexecutorto execute event processing tasks andsequencingPolicythat determines if an event may be processed in sequence or in parallel.- Parameters:
executor- the event processing job executorsequencingPolicy- the policy that determines if an event may be processed in sequence or in parallel
-
-
Method Details
-
handle
public void handle(@Nonnull List<? extends EventMessage<?>> events, @Nonnull Consumer<List<? extends EventMessage<?>>> processor) Description copied from interface:EventProcessingStrategyHandle the given batch ofevents. Once the strategy decides it is opportune to process the events it should pass them back to the givenprocessor.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.
- Specified by:
handlein interfaceEventProcessingStrategy- Parameters:
events- Events to be processedprocessor- Callback method on the processor that carries out the actual processing of events
-
schedule
protected void schedule(List<? extends EventMessage<?>> events, Consumer<List<? extends EventMessage<?>>> processor) Schedules this task for execution when all pre-conditions have been met.- Parameters:
events- The messages to schedule for processingprocessor- The component that will perform the actual processing
-
newProcessingScheduler
protected EventProcessorTask newProcessingScheduler(EventProcessorTask.ShutdownCallback shutDownCallback) Creates a new scheduler instance that schedules tasks on the executor service for the managed EventListener.- Parameters:
shutDownCallback- The callback that needs to be notified when the scheduler stops processing.- Returns:
- a new scheduler instance
-