I am using @Scheduled annotation to run a cron job. The scheduling works for some time, and then stops working. I will give simplified snippets of my code:
This is the scheduler:
//org.springframework.scheduling.annotation.Scheduled
@Scheduled("*/30 * * * * *")
public void performTask() {
logger.info("Starting agent");
getAgentAsyncTask().execute();
logger.info("Ending agent");
}
This is the task which is executed by scheduler
//org.springframework.scheduling.annotation.Async
@Async(TASK_EXECUTOR)
@Override
public void execute() {
logger.info("Starting task");
//send some rest requests
logger.info("Ending task");
}
Both: "Starting agent" and "Ending agent" are logged equal number of times. So, each scheduling is ending properly.
Both: "Starting task" and "Ending task" are logged equal number of times. So, definitely, "task" is not blocking things.
But it just stops logging after some time. What might be the issue?
Here, TASK_EXECUTOR is the following bean:
@Bean(TASK_EXECUTOR)
public ThreadPoolTaskExecutor createDefaultTaskExecutor() {
ThreadPoolTaskExecutor te = new ThreadPoolTaskExecutor();
te.setMaxPoolSize(15);
te.setCorePoolSize(15);
te.initialize();
return te;
}
Spring version:
4.1.6.RELEASE