Class AsynchronousEventProcessingStrategy

java.lang.Object
org.axonframework.eventhandling.async.AsynchronousEventProcessingStrategy
All Implemented Interfaces:
EventProcessingStrategy

public class AsynchronousEventProcessingStrategy extends Object implements 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 Details

    • AsynchronousEventProcessingStrategy

      public 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.
      Parameters:
      executor - the event processing job executor
      sequencingPolicy - 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: EventProcessingStrategy
      Handle the given batch of events. 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.

      Specified by:
      handle in interface EventProcessingStrategy
      Parameters:
      events - Events to be processed
      processor - 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 processing
      processor - 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