org.axonframework.eventhandling.async
Class EventProcessingScheduler<T>

java.lang.Object
  extended by org.axonframework.eventhandling.async.EventProcessingScheduler<T>
Type Parameters:
T - The type of class representing the processing instruction for the event.
All Implemented Interfaces:
Runnable

public abstract class EventProcessingScheduler<T>
extends Object
implements Runnable

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

Since:
1.0
Author:
Allard Buijze

Constructor Summary
EventProcessingScheduler(TransactionManager transactionManager, Executor executor, org.axonframework.eventhandling.async.EventProcessingScheduler.ShutdownCallback shutDownCallback, RetryPolicy retryPolicy, int batchSize, int retryInterval)
          Initialize a scheduler using the given executor.
EventProcessingScheduler(TransactionManager transactionManager, Queue<T> eventQueue, Executor executor, org.axonframework.eventhandling.async.EventProcessingScheduler.ShutdownCallback shutDownCallback, RetryPolicy retryPolicy, int batchSize, int retryInterval)
          Initialize a scheduler using the given executor.
 
Method Summary
protected abstract  void doHandle(T event)
          Does the actual processing of the event.
 void run()
          
 boolean scheduleEvent(T 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

EventProcessingScheduler

public EventProcessingScheduler(TransactionManager transactionManager,
                                Executor executor,
                                org.axonframework.eventhandling.async.EventProcessingScheduler.ShutdownCallback shutDownCallback,
                                RetryPolicy retryPolicy,
                                int batchSize,
                                int retryInterval)
Initialize a scheduler using the given executor. This scheduler uses an unbounded queue to schedule events.

Parameters:
transactionManager - The transaction manager that manages underlying transactions
executor - The executor service that will process the events
shutDownCallback - The callback to notify when the scheduler finishes processing events
retryPolicy - The policy indicating how to deal with event processing failure
batchSize - The number of events to process in a single batch
retryInterval - The number of milliseconds to wait between retries

EventProcessingScheduler

public EventProcessingScheduler(TransactionManager transactionManager,
                                Queue<T> eventQueue,
                                Executor executor,
                                org.axonframework.eventhandling.async.EventProcessingScheduler.ShutdownCallback shutDownCallback,
                                RetryPolicy retryPolicy,
                                int batchSize,
                                int retryInterval)
Initialize a scheduler using the given executor. The eventQueue is the queue from which the scheduler should obtain it's events. This queue does not have to be thread safe, if the queue is not accessed from outside the EventProcessingScheduler.

Parameters:
transactionManager - The transaction manager that manages underlying transactions
executor - The executor service that will process the events
eventQueue - The queue from which this scheduler gets events
shutDownCallback - The callback to notify when the scheduler finishes processing events
retryPolicy - The policy indicating how to deal with event processing failure
batchSize - The number of events to process in a single batch
retryInterval - The number of milliseconds to wait between retries
Method Detail

scheduleEvent

public boolean scheduleEvent(T 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 abstract void doHandle(T 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


Copyright © 2010-2012. All Rights Reserved.