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

java.lang.Object
  extended by org.axonframework.eventhandling.async.AsynchronousExecutionWrapper<T>
Type Parameters:
T - The type of object defining the task

public abstract class AsynchronousExecutionWrapper<T>
extends Object

Abstract implementation that schedules tasks for execution. This implementation allows for certain tasks to be executed sequentially, while other (groups of) tasks are processed in parallel.

Since:
1.0
Author:
Allard Buijze

Constructor Summary
AsynchronousExecutionWrapper(Executor executor, SequencingPolicy<? super T> sequencingPolicy)
          Initialize the AsynchronousExecutionWrapper using the given executor.
AsynchronousExecutionWrapper(Executor executor, TransactionManager transactionManager, SequencingPolicy<? super T> sequencingPolicy, RetryPolicy retryPolicy, int batchSize, int retryInterval)
          Initialize the AsynchronousExecutionWrapper using the given executor and transactionManager.
 
Method Summary
protected abstract  void doHandle(T task)
          Does the actual processing of the task.
protected  EventProcessingScheduler<T> newProcessingScheduler(org.axonframework.eventhandling.async.EventProcessingScheduler.ShutdownCallback shutDownCallback)
          Creates a new scheduler instance that schedules tasks on the executor service for the managed EventListener.
protected  EventProcessingScheduler<T> newProcessingScheduler(org.axonframework.eventhandling.async.EventProcessingScheduler.ShutdownCallback shutDownCallback, Queue<T> taskQueue)
          Creates a new scheduler instance schedules tasks on the executor service for the managed EventListener.
protected  void schedule(T task)
          Schedules this task for execution when all pre-conditions have been met.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

AsynchronousExecutionWrapper

public AsynchronousExecutionWrapper(Executor executor,
                                    TransactionManager transactionManager,
                                    SequencingPolicy<? super T> sequencingPolicy,
                                    RetryPolicy retryPolicy,
                                    int batchSize,
                                    int retryInterval)
Initialize the AsynchronousExecutionWrapper using the given executor and transactionManager. The transaction manager is used to start and stop any underlying transactions necessary for task processing.

Parameters:
executor - The executor that processes the tasks
transactionManager - The transaction manager that will manage underlying transactions for this task
sequencingPolicy - The sequencing policy for concurrent execution of tasks
retryPolicy - The policy for handling failed events
batchSize - The number of events to process in a single batch
retryInterval - The number of milliseconds to wait before a retry

AsynchronousExecutionWrapper

public AsynchronousExecutionWrapper(Executor executor,
                                    SequencingPolicy<? super T> sequencingPolicy)
Initialize the AsynchronousExecutionWrapper using the given executor.

Note that the underlying bean will not be notified of any transactions.

Parameters:
sequencingPolicy - The sequencing policy for concurrent execution of tasks
executor - The executor that processes the tasks
See Also:
AsynchronousExecutionWrapper(java.util.concurrent.Executor, SequencingPolicy)
Method Detail

doHandle

protected abstract void doHandle(T task)
Does the actual processing of the task. This method is invoked if the scheduler has decided this task is up next for execution. Implementation should not pass this scheduling to an asynchronous executor.

Parameters:
task - The task to handle

schedule

protected void schedule(T task)
Schedules this task for execution when all pre-conditions have been met.

Parameters:
task - The task to schedule for processing.

newProcessingScheduler

protected EventProcessingScheduler<T> newProcessingScheduler(org.axonframework.eventhandling.async.EventProcessingScheduler.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

newProcessingScheduler

protected EventProcessingScheduler<T> newProcessingScheduler(org.axonframework.eventhandling.async.EventProcessingScheduler.ShutdownCallback shutDownCallback,
                                                             Queue<T> taskQueue)
Creates a new scheduler instance schedules tasks on the executor service for the managed EventListener. The Scheduler must get tasks from the given taskQueue.

Parameters:
shutDownCallback - The callback that needs to be notified when the scheduler stops processing.
taskQueue - The queue from which this scheduler should store and get tasks
Returns:
a new scheduler instance


Copyright © 2010-2012. All Rights Reserved.