0
votes

I have an UI Interface where user can define Job name, interval, active/Inactive etc.

How we can achieve this with Quartz Scheduler or any java/Spring api ?

Ex. Suppose any Quartz job is started and interval is set as 10 min, So in ideal case job will run in next 10 min interval. But every time job runs we want to fetch the latest interval from database and schedule it.

10:00 Job runs and in the database interval is set to 10 min 10:10 Job runs and in the database interval is set to 20 min

So next time job should run at 10:30

1

1 Answers

1
votes

If you use Quartz, you can implement a custom Trigger. Your implementation would lookup the value in the database and return when the next time the run should happen in the getFireTimeAfter.

Another option is to use Spring Scheduling APIs and implement the Trigger interface. Same here, the nextExecutionTime method would decide when the next run should happen.

The advantage of using a custom implementation is that you have full control over the triggering logic (like in your case, do a lookup in the database and dynamically set the next run time).