I have a simple Spring Boot app that handles some REST API calls and so on. I added @EnableScheduling
to my main class and then proceeded to add @Scheduled
on top of each function I need to schedule and then added a cron expression.
Spring boot Version : 2.7.1
What I have is the following:
I have three classes. Each class contains a void function scheduled.
I ran the app and everything seems working fine. All the API calls ran smoothly and as excepted, and then I ran the same app but from a jar file using the cmd. The scheduler works fine the first day and then suddenly stops working and then starts working again the day after.
I was monitoring the logs and it turned out that 4 out of 5 days the scheduler ran as expected, but skipped one day for no reason.
Any one might experienced this weird behavior?
main class:
@EnableScheduling
@SpringBootApplication
public class MYCLASSHERE {
public static void main(String[] args) {
SpringApplication.run(MYCLASSHERE.class, args);
}
}
each class has the following structure:
@Service
public class MYOTHERCLASS{
@Scheduled(cron = "0 5 12 * * *")
public void FUNCTION() {}
}
@Service
public class MYOTHERCLASS{
@Scheduled(cron = "0 10 12 * * *")
public void FUNCTION() {}
}
@Service
public class MYOTHERCLASS{
@Scheduled(cron = "0 15 12 * * *")
public void FUNCTION() {}
}
Note that everything is working fine. The scheduler stoppage that I'm experiencing is the only problem when running from a jar file.