Suneel
Suneel

Reputation: 827

what happens to a currently running quartz job when server is shutdown

We have a SQL based quartz scheduler. There is a job that processes 100k records and runs for 2 hours. If a server shutdown is initiated with the job still running, will the job start again after the server is restarted?

Upvotes: 1

Views: 2625

Answers (2)

Dhiral Kaniya
Dhiral Kaniya

Reputation: 2051

You need to store your scheduler details JDBC JobStore when you are creating Scheduler factory with JDBC configuration properties.

After that, you can extract it from the metadata and according to the failure time you can retrieve your scheduler details and resume it according to your requirement.

Please refer:- Quartz Scheduler using JDBC JobStore

One more alternative way is that you can create your own Scheduler Listener and assign it to the scheduler. Reference :- https://examples.javacodegeeks.com/enterprise-java/quartz/quartz-scheduler-tutorial/

Upvotes: 1

Dhananjay
Dhananjay

Reputation: 3975

Check

RequestsRecovery - if a job "requests recovery", and it is executing during the time of a 'hard shutdown' of the scheduler (i.e. the process it is running within crashes, or the machine is shut off), then it is re-executed when the scheduler is started again. In this case, the JobExecutionContext.isRecovering() method will return true.

As long as you have JDBCData store, this will work.

Upvotes: 3

Related Questions