Skip to content
Advertisement

Spring Boot @Schedular not running after first execution

I have written this scheduled task in my SpringBoot app:

@Component
public class TestTaskScheduler {

    @Scheduled(fixedRate = 1000)
    public void test() {
        System.out.println("Run again and again and again");
    }
}

This runs first time, but not subsequently.

Advertisement

Answer

It turned out that I was running another “heavy” scheduled task in the same application (it was initially created for testing my business logic and then I forgot to remove that). When I removed the other task, the issue got resolved. (It seems that another task was using most of the resources so the current task was waiting for long time to be scheduled again.)

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement