A Job is a continuation that batches together other continuations, specifically {@link Event}s, into one continuation. The {@link Event}s themselves provide methods to process themselves, so processing a job simply consists of sequentially processing all of its aggregated events. The constructor accepts a maximum number of events for the job, and only runs up to that maximum number when processing the job, but the add method does not enforce this maximum. In other words, not all the enqueued events may be processed in each run of the job, several runs may be required to clear the queue.
CRC Card Responsibilities | Collaborations |
---|
Aggregate many coninuations together into a single continuation. |
Sequentially process aggregated continuations. | {@link Event} |
Provide running and completion status of the aggregate continuation. |
Execute a terminal continuation upon job completion. | {@link JobCompletionHandler} |
@todo Could make Job implement Runnable, FutureTask, or a custom Continuation interface, to clarify its status as acontinuation. Job is a continuation that aggregates other continuations and as such is a usefull re-usable piece of code. There may be other palces than the mina filter chain where continuation batching is used within qpid, so abstracting this out could provide a usefull building block. This also opens the way to different kinds of job with a common interface, e.g. parallel or sequential jobs etc.
@todo For better re-usability could make the completion handler optional. Only run it when one is set.