How to restart scheduled task on runtime with EnableScheduling annotation in spring?

后端 未结 4 599
南笙
南笙 2021-01-01 21:25

I have been investigating how to change the frequency of a job on runtime with Java 8 and spring. This question was very useful but it did not totally solve my issue.

<
4条回答
  •  自闭症患者
    2021-01-01 22:09

    What about using Set ScheduledTaskRegistrar.getScheduledTasks() to get all schedules tasks and calling ScheduledTask::cancel() ? or maybe executing ThreadPoolTaskScheduler::shutdown() and recreating ThreadPoolTaskScheduler and setting it again in ScheduledTaskRegistrar ?

提交回复
热议问题