Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Java – Create a workflow in Quartz

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".

like image 497
Adrian Avatar asked Oct 13 '09 11:10

Adrian


2 Answers

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.

like image 71
Jon Quarfoth Avatar answered Oct 31 '22 15:10

Jon Quarfoth


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 ?

like image 28
Brian Agnew Avatar answered Oct 31 '22 16:10

Brian Agnew