views:

537

answers:

2

I am considering using the Quartz framework to schedule the run of several hundred jobs.

According to their API, jobs can be scheduled to run at certain moments in time but not to run one after the other (and stop a chain of jobs if one fails). The only recommended methods I was able to find are:

  • Using a listener which notices the completion of a job and schedule the next trigger to fire (how to coordinate this?)
  • Each job will receive a parameter containing the next job to run and, after completing the actual work, schedule its run. (Cooperative)

Do you know a better method to create a workflow of jobs in Quartz?

Can you recommend other methods/framework for implementing a workflow in Java ?

EDITED: In the meantime I found out about OSWorkflow which appears to be a good match for what I need. It appears that what I need to implement is a "Sequence Pattern".

+1  A: 

It sounds to me like you want Quartz to schedule the first job, and chain everything off that.

Have you looked at encapsulating each task using the Command Pattern, and linking them together ?

Brian Agnew
+2  A: 

When Quartz documentation talks about "Job", it is referring to a class implementing the "Job" Interface, which is really just any class with an "execute" method that takes in the Quartz Context object. When creating this implementation you can really do whatever you want.

You could create an implementation of the Quartz Job Interface which simply calls all the jobs in your workflow in series, and throws a JobExecutionException exception on failure.

Jon Quarfoth