Author |
Message |
04/14/2010 08:14:22
|
budducci
neo
Joined: 04/14/2010 08:04:29
Messages: 2
Offline
|
I apologize in advance, since this topic has probably been brought up before, but I was unable to find with a search.
We are currently using quartz and have it set up so several jobs are chained together:
When A completes then B automatically triggers, and when B completes then C and so on.
Logically we have a setup where A and B aren't dependent on eachother, though C is:
A and B can run at the same time, but C can only run when both A and B are complete.
Is there a way to set this kind of scenario up in Quartz, so that C will only trigger when A and B finish?
|
|
|
04/14/2010 08:30:37
|
QrtzHelp
journeyman
Joined: 01/16/2010 09:44:00
Messages: 37
Offline
|
Workflow features have been out of the scope of Quartz so far, though it is a frequent topic.
There is a FAQ entry:
http://www.quartz-scheduler.org/docs/faq.html#FAQ-chain
You may also want to look at:
http://www.quartz-scheduler.org/docs/api/org/quartz/listeners/JobChainingJobListener.html
|
|
|
04/14/2010 08:36:09
|
budducci
neo
Joined: 04/14/2010 08:04:29
Messages: 2
Offline
|
OK, thanks for the quick response.
|
|
|
04/22/2010 15:57:32
|
johnlfox
neo
Joined: 04/22/2010 15:45:23
Messages: 2
Offline
|
I created a 'poor mans' dependency by using database tables in the quartz database to describe what jobs a job depended on, and to log the status in another table when jobs end (i.e. did it throw an exception or end cleanly). I also start a wrapper that will start a scheduler, then walk through the status 'failing' jobs that were running when last shutdown, or restarting jobs that were waiting.
I describe it as a 'poor mans' method because the job is actually fired, but then enters a method where it checks the database to see if all dependencies are cleared. If not, it goes to sleep and tries again. This method depends on all jobs to extend a class, and the to code the execute method to run a 'start' method before doing any real work.
This means that every job that is waiting for a dependency has been executed based on their trigger/scheduler and is taking up resources.
What I would really like to do is figure out how to wrap this dependency into a trigger or the scheduler. Chaining doesn't really work ... I want jobs X to run at 1am, but only if job Y has completed in the last 3 hours. Any ideas??
I have written a GUI scheduler system for Quartz and have gotten permission to release the code. This is one of the last steps in doing so, creating a dependency system that executes based on triggers, calendars, and dependencies. I have all the database tables to support, I just haven't been able to figure out how to implement it inside of Quartz.
The GUI is really cool ... it provides logging, job status visibility, job dependency across multiple schedulers, basic tasks (such as FTP, file manipulation, email, SQL execution). I just need to fix this one thing.....
|
|
|
04/22/2010 16:23:04
|
jhouse
seraphim
Joined: 11/06/2009 15:29:56
Messages: 1703
Offline
|
The best way to "build it into" Quartz would be to create a plugin that sets up trigger and/or job listeners to monitor what is completing and then kick off (schedule) follow-up jobs.
Until Quartz 2.0 (months away), to actually put it into Quartz itself would mean literally extending and overriding significant amounts of code in the heart of the Quartz codebase. And it wouldn't make sense to do that, unless the API was also changed to support describing the dependencies.
|
|
|
04/22/2010 16:59:33
|
johnlfox
neo
Joined: 04/22/2010 15:45:23
Messages: 2
Offline
|
I agree 100% that is a good way with the existing code. I just don't like watching for events and then firing things ... it's too easy for things to get missed and there is a single point of failure (i.e. the plug in).
Because all jobs are already submitted, I can see what time any job is due to fire based on their trigger, and once they fire, what they are waiting on. Pushing jobs onto the queue doesn't easily provide this type of capability and is prone to missed messages. For instance, I would have to interrogate the trigger to find what time each job is due to fire instead of just asking Quartz. I'd much rather have a trigger get ready to fire, say 'opps ... not now', and then reschedule 5 minutes from now instead of the next time it is due. I just can't figure out how to do it, or if it's possible. I've read through some of the Quartz code, but haven't been able to spend a lot of time on it. We only use Cron triggers, so if I could figure it out it wouldn't take much to implement it.
I'll keep working on it though ... as much as that pesky production work that they pay me to do allows me to spend time on it.
|
|
|
|