Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

JavaQuartz Job persistence

I am not much familiar with Java Quartz, we just used a test job thats scheduled daily. For our Struts2 webapplication, we want to run a few daily jobs that are scheduled at different times of the day. The jobs should be in persistence state such that even if the jobs fails due to server down/application failed, they should re-execute later when server is up. Also can i store the status/results of the jobs in DB, so as to monitor the jobs. Any suggestions would be helpful.

-- Thanks

like image 309
Sangram Anand Avatar asked Jun 25 '12 08:06

Sangram Anand


3 Answers

Whatever you have mentioned is possible in Quartz scheduler and there is already a feature with triggers which we generally call Misfire Instructionsthis is what doc say about it

Another important property of a Trigger is its "misfire instruction". A misfire occurs if a persistent trigger "misses" its firing time because of the scheduler being shutdown, or because there are no available threads in Quartz's thread pool for executing the job. The different trigger types have different misfire instructions available to them. By default they use a 'smart policy' instruction - which has dynamic behavior based on trigger type and configuration. When the scheduler starts, it searches for any persistent triggers that have misfired, and it then updates each of them based on their individually configured misfire instructions. When you start using Quartz in your own projects, you should make yourself familiar with the misfire instructions that are defined on the given trigger types, and explained in their JavaDoc. More specific information about misfire instructions will be given within the tutorial lessons specific to each trigger type.

Regarding Job persistence Quartz comes with few build in mechanism and all you need to set JobStore as JDBCJobStore

I suggest you to go with Quartz scheduler document its quite easy and have lots of tutorial and examples to start with.

If you are not using Spring in your application there is no need to add extra level of abstraction and dependencies.

like image 54
Umesh Awasthi Avatar answered Oct 19 '22 03:10

Umesh Awasthi


You can use Quartz combined with Sprig batch.

The former provides API for managing various flows (as complex as you need), persistent storage of job state and api for monitoring and re-running jobs according to their execution status. Another handy library is Spring Batch admin. It has web console and 5 minutes guide.

Quartz is used as scheduler job state persistence is handled by Spring batch.. It can run as standalone java application and also in web/application container (for me Tomcat was enough).

Good luck!

like image 38
aviad Avatar answered Oct 19 '22 03:10

aviad


We have Job stores api in Java Quartz. This will persist data in the databases about the information of the Job. So i guess this will help you. You can check this link to get an idea about code and DB structure.

like image 23
Arun Avatar answered Oct 19 '22 04:10

Arun