quartz jobDetail requestRecovery

user1746050 picture user1746050 · Oct 9, 2013 · Viewed 7.9k times · Source

The documentation for JobDetail.requestsRecovery property states the following

Instructs the Scheduler whether or not the Job should be re-executed if a 'recovery' or 'fail-over' situation is encountered.

Now, what is a 'recovery' situation or a 'fail-over' situation?

How are they different?

Does the recovery happen only if the JVM crashes during job execution or does it happen if the job execution fails because of an exception also?

Answer

zerologiko picture zerologiko · Oct 9, 2013

A "Recovery situation" is the generic term, one kind of recovery situation is the "fail-over".

A fail-over is a process used by fault-tolerance systems generally used with redundancy (e.g. clustering). Quartz use fail-over when is used in clustering and more Quartz "nodes" exists.

Quoting documentation:

Fail-over occurs when one of the nodes fails while in the midst of executing one or more jobs. When a node fails, the other nodes detect the condition and identify the jobs in the database that were in progress within the failed node. Any jobs marked for recovery (with the "requests recovery" property on the JobDetail) will be re-executed by the remaining nodes.

A recovery situation is every situation that produce an "Hard-shutdown" (i.e. the process it is running within crashes, or the machine is shut down).


To answer your second question:

  • If the JVM crashes during a job execution > Quartz will recover the job

    (Because a crash is Recovery situation)

  • if the job execution fails because of an exception > Quartz will not recover the job

    (Because exception is not an hard-shutdown, a misfire is thrown instead)

See this answer to activate recovery for your jobs.