-
Notifications
You must be signed in to change notification settings - Fork 40
Description
In Concurrency 3.1, the new @Schedule annotation that nested in @Asynchronous has some issues in the real world applications.
- The attributes
hour/minute/secondetc., are just another duplicated form of thecron. - It does not cover the simple
fixedRate/intervalcase.
I hope there is a new annotation that refer to the definition from Spring @Scheduled, cover both simple fixed rate settings and cron expression, also consider EL (via Jakarta Config properties/env) support.
public @interface Scheduled { // a modified versoin of spring @Scheduled
String cron() default ""; //also should support EL
ZoneId zone() default UTC;
long fixedRate() default -1;
String fixedRateExpression() default ""; // accept EL
long fixedDelay() default -1;
String fixedDelayExpression() default ""; // accept EL
long initialDelay() default -1;
String initialDelayExpression() default ""; // accept EL
TimeUnit timeUnit() default TimeUnit.MILLISECONDS;
String executor() default ""; //scheduledExecutorService name or change it to Qualifier to match the executor to run this scheudule
}Of course, in theory, it is possible to add the missing attributes to the existing @Schedule.
However, if we add the missing fixedRate related attributes to @Schedule and allow it to use on methods, then we will face another issue: we have to add a executor attribute to @Schedule to set up the executor service used to run the scheduling tasks, which make the @Asychronous looks weird, because @Asynchronous itself includes an executor.
@Schedule(executor=...)
public void aMethod()
@Asynchronous(executor=..., runAt={@Schedule(executor=...)}...)
public void bMethod()Originally it is discussed here, #624 (comment)