Current quartz work when Tomcat is killed

I don `t understand. Say I have jobs randomly scheduled during the day, and each job takes 30 minutes. Say I have five of these jobs and Tomcat is killed. Are jobs reloaded when I start Tomcat with my application or are current work orders lost because they are already running?

+7
source share
2 answers

Short answer, by default, jobs currently running are considered to be running and not restored

... but you can set the requestRecovery property when creating a job (JobDetail) to tell Quartz to restore running tasks if aka "hard shutdown" fails.

Quoting the official documentation here at the bottom of the page:

RequestsRecovery - if the task “requests recovery” and is executed during the “hard shutdown” of the scheduler (that is, the process that it runs in the event of a failure or the machine is turned off), then it runs again when the scheduler starts again. In this case, the JobExecutionContext.isRecovering () method will return true.

So what you can do, for example:

import static org.quartz.JobBuilder.*; ... JobDetail job = newJob(MyJob.class) .withIdentity("myJob", "group1") .requestRecovery(true) //This is the guy! .build(); ... 
+14
source

Tomcat does not care about your work. Your task is to correctly complete the work in your web application when it is closed.

0
source

Source: https://habr.com/ru/post/955111/


All Articles