org.axonframework.eventhandling.async
Class EventProcessor

java.lang.Object
  extended by org.axonframework.eventhandling.async.EventProcessor
All Implemented Interfaces:
Runnable

public class EventProcessor
extends Object
implements Runnable

Scheduler that keeps track of (Event processing) tasks that need to be executed sequentially.

Since:
1.0
Author:
Allard Buijze

Nested Class Summary
protected static class EventProcessor.ProcessingResult
          Class indicating the result of Event Processing and the policy for resuming or retrying in case of errors.
static interface EventProcessor.ShutdownCallback
          Callback that allows the SequenceManager to receive a notification when this scheduler finishes processing events.
 
Constructor Summary
EventProcessor(Executor executor, EventProcessor.ShutdownCallback shutDownCallback, ErrorHandler errorHandler, UnitOfWorkFactory unitOfWorkFactory, Set<EventListener> eventListeners, MultiplexingEventProcessingMonitor eventProcessingMonitor)
          Initialize a scheduler using the given executor.
 
Method Summary
protected  EventProcessor.ProcessingResult doHandle(EventMessage<?> event)
          Does the actual processing of the event.
 void run()
          
 boolean scheduleEvent(EventMessage<?> event)
          Schedules an event for processing.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

EventProcessor

public EventProcessor(Executor executor,
                      EventProcessor.ShutdownCallback shutDownCallback,
                      ErrorHandler errorHandler,
                      UnitOfWorkFactory unitOfWorkFactory,
                      Set<EventListener> eventListeners,
                      MultiplexingEventProcessingMonitor eventProcessingMonitor)
Initialize a scheduler using the given executor. This scheduler uses an unbounded queue to schedule events.

Parameters:
executor - The executor service that will process the events
shutDownCallback - The callback to notify when the scheduler finishes processing events
errorHandler - The error handler to invoke when an error occurs while committing a Unit of Work
unitOfWorkFactory - The factory providing instances of the Unit of Work
eventListeners - The event listeners that should handle incoming events
eventProcessingMonitor - The listener to notify when processing completed
Method Detail

scheduleEvent

public boolean scheduleEvent(EventMessage<?> event)
Schedules an event for processing. Will schedule a new invoker task if none is currently active.

If the current scheduler is in the process of being shut down, this method will return false.

This method is thread safe

Parameters:
event - the event to schedule
Returns:
true if the event was scheduled successfully, false if this scheduler is not available to process events
Throws:
IllegalStateException - if the queue in this scheduler does not have the capacity to add this event

run

public void run()

Specified by:
run in interface Runnable

doHandle

protected EventProcessor.ProcessingResult doHandle(EventMessage<?> event)
Does the actual processing of the event. This method is invoked if the scheduler has decided this event is up next for execution. Implementation should not pass this scheduling to an asynchronous executor

Parameters:
event - The event to handle
Returns:
the policy for retrying/proceeding with this event


Copyright © 2010-2016. All Rights Reserved.