I want to configure scheduler in my application where I have to set cron expression with database values dynamically. When application starts, a method should fetch the database values in set them in cron expression for a particular job. Please help me with this. I am all new to quartz scheduler, spring scheduler concepts
Asked
Active
Viewed 7,933 times
2 Answers
3
You can very well use TaskScheduler
class of Spring Scheduling
in this case.
Please have a look at the class definition:
scheduler.schedule(runnableTask, new CronTrigger(cron, TimeZone.getTimeZone(timezone)));
You can create a runnable task as follows:
class RunnableTask implements Runnable {
@Override
public void run() {
//
}
}
While creating a cron
trigger, you can load cron expression from database
.

shankarsh15
- 1,947
- 1
- 11
- 16
0
You may want to look at this answer. https://stackoverflow.com/a/4499229/82632
Basically you need to autowire TaskScheduler
class then programmatically add jobs with it.