0

I have 2 jobs, one runs every hour, the second one runs once per day. Theoretically every job's execution could be longer than hour (or even several hours).

These jobs mustn't be executed at the same time.
So I should implement some checking, if the another one is running, then wait when it finishes, and start execution. How can I implement this (using Quartz)?

Edit: @DisallowConcurrentExecution doesn't help, because it skips execution without waiting when another job finishes.

Taras Kohut
  • 2,505
  • 3
  • 18
  • 42
  • Is `synchronized` OK for you? – Boris Schegolev Nov 01 '16 at 12:52
  • Possible duplicate of [How to set to a QUARTZ JOB to start only when an another JOB finished, stopped?](http://stackoverflow.com/questions/22861365/how-to-set-to-a-quartz-job-to-start-only-when-an-another-job-finished-stopped) – Erwin Bolwidt Nov 01 '16 at 12:54
  • @BorisShchegolev yes, it is – Taras Kohut Nov 01 '16 at 12:57
  • @ErwinBolwidt I've updated the question – Taras Kohut Nov 01 '16 at 13:00
  • @TarasKohut What makes you think that it skips the execution? [What happens to jobs affected by Quartz DisallowConcurrentExecution](http://stackoverflow.com/questions/5835109/what-happens-to-jobs-affected-by-quartz-disallowconcurrentexecution) – Erwin Bolwidt Nov 01 '16 at 13:14
  • @ErwinBolwidt ok, looks like it doesn't skip the execution but postpones it. The only issue is that this annotation tells Quartz not to execute multiple instances of a given job definition, it means that I can't use it for synchronizing several Jobs – Taras Kohut Nov 01 '16 at 14:16

1 Answers1

1

I have a similar problem and solve it using a TriggerListener to put jobs in a queue, based on JobChainingJobListener

jpozorio
  • 622
  • 6
  • 7