6

How can I handle the "exceptions" caused by a job run by Quartz scheduler so that it is run on the following scheduled time. I don't want it to refireImmediately or I don't want it to drop this job. Just keep it in the jobstore until its next turn.

Sam
  • 2,702
  • 5
  • 31
  • 45

1 Answers1

6

If you throw an exception from a Job and it is not JobExecutionException with refireImmediately set, this execution will be discarded and proceed with normal schedule. E.g. when a job is suppose to run every 10 seconds and a single execution threw an exception, Quartz will simply discard this exceution and run next one after 10 seconds.

Unfortunately the only way of refiring with some delay is a custom code (maybe a JobListener implementation?), refireImmediately does what it says. It is a pity Quartz does not support it out-of-the-box.

See a proposed solution here (but not the accepted answer): Quartz retry when failure.

Community
  • 1
  • 1
Tomasz Nurkiewicz
  • 334,321
  • 69
  • 703
  • 674
  • But if throw with refireImiddiatelly, will it be run on the same node or not? In multi node env with jdbc store. Say, if current node is too busy and throw an exception to let som other node handle it. – ses Dec 16 '21 at 03:01