This is my code :
@Scheduled(cron = "30 3 * * * *")
public void myCron() {
//we don't care what we do here
}
I want to know if it is possible to add a tracking id (or other information) on my @Scheduled
automatically.
The id will be different each time @Scheduled
is triggered.
I want to do this to avoid to duplicate code like :
@Scheduled(cron = "10 3 * * * *")
public void myCron() {
MDC.put("myId", UUID.randomUUID().toString());
//we don't care what we do here
}
@Scheduled(cron = "30 3 * * * *")
public void mySecondCron() {
MDC.put("myId", UUID.randomUUID().toString());
//we don't care what we do here
}
I tired to implements SchedulingConfigurer
but SchedulingConfigurer#configureTasks
is too late too add behavior on taks because the task (runnable) is already created
Thanks