Search code examples
javaspringscheduled-tasksquartz-scheduler

How to change Spring's @Scheduled fixedDelay at runtime?


I have a requirement to run a batch job at a fixed interval and have the ability to change the time of this batch job at runtime. For this I came across @Scheduled annotation provided under Spring framework. But I'm not sure how I'd change the value of fixedDelay at runtime. I did some googling around but didn't find anything useful.


Solution

  • You can use a Trigger to dynamically set the next execution time.

    See my answer to Scheduling a job with Spring programmatically for details.