私のスプリングブートアプリでは、スケジュールされたタスクをプログラムで作成しています。
@Configuration
@EnableScheduling
public class AppConfig implements SchedulingConfigurer {
@Override
public void configureTasks(ScheduledTaskRegistrar taskRegistrar) {
taskRegistrar.setScheduler(taskScheduler());
//following loop will get executed according to requirement for now //just looping 0-9
for(int i=0;i<10;i++){
MyRunnable myRunnable=new MyRunnable();
myRunnable.setID(i);
taskRegistrar.addTriggerTask(myRunnable,new CronTrigger("0 0/15 * * * *"));
}
}
@Bean(destroyMethod="shutdown")
public Executor taskScheduler() {
return Executors.newScheduledThreadPool(42);
}
@Bean
public MyTask myTask() {
return new MyTask();
}
}
上記のタスクをその場で再スケジュールする方法が必要ですが、上記の作業を完了するのを手伝ってくれる人はいますか? myRunnable.getID()のような ID でタスクを再スケジュールすることをお勧めします。どんな助けでも大歓迎ですか?
私はコントローラーでフォローしようとしました
@Autowired
private ScheduledTaskRegistrar scheduledTaskRegistrar;
しかし、コントローラーに注入していません