Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What framework to use for advanced job scheduling in Java?

In my application I need to have periodically run background tasks (which I can easily do with Quartz - i.e. schedule a given job to be run at a specific time periodically).

But I would like to have a little bit more control. In particular I need to:

  1. have the system rerun a task that wasn't run at its scheduled time (i.e. the server was down and because of this the task was not run. In such a situation I want the 'late' task to be run ASAP)
  2. it would be nice to easily control tasks - i.e. run a task on demand or see when a given task was last run or reschedule a given task to be run at a different time

It seems to me that the above points can be achieved with Spring Batch Admin, but I don't have much experience in this area yet. Also, I've seen numerous posts on how Spring Batch is not a scheduling tool so I'm becoming to have doubts what the right tool for the job is here.

So my question is: can the above be achieved with Spring Batch Admin? Or perhaps Quartz is enough but needs configuring to do the above? Or maybe I need both? Or something else?

Thanks a lot :) Peter

like image 633
machinery Avatar asked Dec 08 '11 17:12

machinery


1 Answers

have the system rerun a task that wasn't run at its scheduled time

This feature in Quartz is called Misfire Instructions and does exactly what you need - but is a lot more flexible. All you need is to define JDBCJobStore.

it would be nice to easily control tasks - i.e. run a task on demand or see when a given task was last run or reschedule a given task to be run at a different time

You can use Quartz JMX to access various information (like previous and next run time) or query the Quartz database tables directly. There are also free and commercial management tools basex on the above input. I believe you can also manually run jobs there.

Spring Batch can be integrated with Quartz, but not replace it.

like image 111
Tomasz Nurkiewicz Avatar answered Sep 22 '22 15:09

Tomasz Nurkiewicz