[Logo] Terracotta Discussion Forums
  [Search] Search   [Recent Topics] Recent Topics   [Members]  Member Listing   [Groups] Back to home page 
[Register] Register / 
[Login] Login 
[Expert]
Prevent jobs from concurrent execution  XML
Forum Index -> Quartz
Author Message
clemente

neo

Joined: 06/09/2011 09:15:17
Messages: 3
Offline

Hi,

I'm quite new to Quartz and may be asking something stupid right now. But I cannot find any information about preventing concurrent execution of different jobs.

I do have several jobs including group1.job1 (Job1.class) and group1.job2 (Job2.class) that must not run concurrent.

Can I tell Quartz somehow to wait with triggering one of these Jobs until the end of the other one if for some reason the other one is still running?

Thanks a lot,
Clemens
light5

ophanim
[Avatar]
Joined: 01/14/2011 20:32:56
Messages: 501
Offline

If you make your job "Stateful", then one of the sideeffect is NOT to be able run concurrently. See "StatefulJob" under http://quartz-scheduler.org/docs/1.x/tutorial/TutorialLesson03.html

Zemian Deng
---------------
Looking for a web UI to manage Quartz?
Try http://code.google.com/p/myschedule
[WWW]
clemente

neo

Joined: 06/09/2011 09:15:17
Messages: 3
Offline

Thank you for your reply.

I already read about stateful jobs. As far as I understand them, quartz prevents one stateful job to be executed in more than one instance concurrently.

I face the situation, that I have two (in fact six) different jobs that must not run concurrent. If Job1 (Job1.class implements Job) runs, Job2 (Job2.class implements Job) must wait until Job1 has finished.
IMHO quartz runs Job1 and Job2 parallel even if they are stateful. Or did I misunderstood stateful jobs?

Clemens
Jeh

journeyman

Joined: 05/18/2011 02:52:11
Messages: 10
Offline

Have you considered to put your jobs in the same class and use job instance fonctionnality ?
You could use annotations like "DisallowConcurrentExecution" to prevent 2 job instances to run concurrently (see http://quartz-scheduler.org/docs/tutorial/TutorialLesson03.html)

It's just an idea, I've never done something like that and I don't know if it fits your need
Jeh

journeyman

Joined: 05/18/2011 02:52:11
Messages: 10
Offline

This may help you too : http://www.quartz-scheduler.org/docs/faq.html#FAQ-chain
loriente

journeyman

Joined: 05/10/2011 12:10:29
Messages: 37
Offline

For what you describe Job1.class and Job2.class are not the same Job so you will not get the stateful behavior you are looking for.

If you were to schedule Job1.class to fire at 12:00 and then at 12:01 but first run still going then second run 12:01 will wait till previous one finishes. That is because you are scheduling the same Job with two different triggers. Which is not your case where you have 2 completely different jobs.

From the documentation (link posted by Jeh) I think your best option is
Another way is to build a Job that contains within its JobDataMap the name of the next job to fire, and as the job completes (the last step in its execute() method) have the job schedule the next job. 



nicolas.loriente
clemente

neo

Joined: 06/09/2011 09:15:17
Messages: 3
Offline

Thanks for all suggestions.

After lots of reading and trying I will try the following strategy... Just in case someone else with similar questions reads this. ;-)

I implement one stateful job class as "master" and n jobs for the actual work.

I do only trigger master. Based on the trigger's name causing master to execute, master instantiates one of the n jobs and delegates the work.

This procedure allows me weaker coupling of the n jobs in terms of chaining and quartz grants the non-parallel execution.

The only open question is how to store the job configuration in the JobDataMap. I'm looking forward to store a configuration-map for each trigger in master's JobDataMap. If done, master can fetch the correct configuration and pass it to the delegate.

Greets, Clemens
gyan10

ophanim

Joined: 06/28/2011 23:15:25
Messages: 697
Offline

This is an old thread and no update from a long time.Please let us know if you are still facing same issue.
Thanks

Gyan Awasthi
Terracotta -A Software AG company
 
Forum Index -> Quartz
Go to:   
Powered by JForum 2.1.7 © JForum Team