I have several methods annotated with @Scheduled(fixedDelay=10000)
.
In the application context, I have this annotation-driven setup:
<
A method annotated with @Scheduled
is meant to be run separately, on a different thread at a moment in time.
If you haven't provided a TaskScheduler
in your configuration, Spring will use
Executors.newSingleThreadScheduledExecutor();
which returns an ScheduledExecutorService
that runs on a single thread. As such, if you have multiple @Scheduled
methods, although they are scheduled, they each need to wait for the thread to complete executing the previous task. You might keep getting bigger and bigger delays as the the queue fills up faster than it empties out.
Make sure you configure your scheduling environment with an appropriate amount of threads.