I have a method which is scheduled to run after every 20 minutes. I simply used @Scheduled annotation in Spring boot , However I need a scheduler which takes delay time at runtime. E.g. If I want to be able to change the delay time/frequency of method execution at runtime without stopping the application i.e. change the frequency in DB and Code should adapt it.
@Scheduled(initialDelay=15*60*1000, fixedRate=20*60*1000)
public void MyMethod() {
// Code to repeat after every 20 minutes
}
}
The fixed rate in the code should be variable and taken at the runtime. Is it possible to achieve it ?