Peter Szanto opened SPR-16271 and commented
I would like to have multiple scheduled tasks in my application, with multiple their pool size, thread name and some as daemon. I can customize these properties using a TaskScheduler, but in an single application I can have only one TaskScheduler. It would be nice if I could define multiple schedulers and refer them in the @Scheduled
annotation similar as I can refer cache name in the @Cacheable
annotation. There could be even something similar to @CacheConfig
so class level settings for multiple scheduled definitions could be configured
Affects: 4.3.13
Comment From: Axinet
It is also worth to mention that @Async
annotation also working on executors has already such option since 3.1.2. I am really surprised that @Scheduled
annotation has been skipped then.
Comment From: warrior107
Hi, Is someone working on this? Or is there a workaround for the time being?
Comment From: idkw
Hello, I also need this. Current workaround is to call an @Async method from a @Scheduled method but this is very confusing to maintain
Comment From: idkw
Another workaround but it would be simpler for it to be supported directly via the annotation. The @Scheduled annotation processor in spring builds a ScheduledMethodRunnable instance as the Runnable passed into the TaskScheduler so theorically we could build a TaskScheduler wrapper that plays the role of a dispatcher that uses the method name to select which actual TaskScheduler to use.
But again, a native support would be very much appreciated
From : org.springframework.scheduling.annotation.ScheduledAnnotationBeanPostProcessor
Comment From: dantebarba
@idkw great answer!. Can you post the generic dispatcher code into some gist? Thanks.
Comment From: idkw
@idkw great answer!. Can you post the generic dispatcher code into some gist? Thanks.
I don't have any code, this was just an idea of a possible workaround
Comment From: marwin1991
any progres ?
Comment From: jhoeller
This is finally coming in 6.1 now: with a scheduler
attribute on @Scheduled
and supporting infrastructure underneath, including a qualifier value on SchedulingAwareRunnable
and ScheduledMethodRunnable
. Note that this is analogous to the transactionManager
attribute on @Transactional
, even more so than the qualifier value on @Async
.