@Target(value=METHOD) @Retention(value=RUNTIME) @Repeatable(value=Scheduled.Schedules.class) public @interface Scheduled
The schedule is defined either by cron()
or by every()
attribute. If both are specified, the cron
expression takes precedence.
@ApplicationScoped class MyService { @Scheduled(cron = "0/5 * * * * ?") void check() { // do something important every 5 seconds } }The annotated method must return
void
and either declare no parameters or one parameter of type
ScheduledExecution
.ScheduledExecution
Modifier and Type | Optional Element and Description |
---|---|
Scheduled.ConcurrentExecution |
concurrentExecution
Specify the strategy to handle concurrent execution of a scheduled method.
|
String |
cron
Defines a cron-like expression.
|
long |
delay
Delays the time the trigger should start at.
|
String |
delayed
Defines a period after which the trigger should start.
|
TimeUnit |
delayUnit |
String |
every
Defines a period between invocations.
|
String |
identity
Optionally defines a unique identifier for this job.
|
public abstract String identity
If the value is not given, Quarkus will generate a unique id.
public abstract String cron
If the value starts with "{" and ends with "}" the scheduler attempts to find a corresponding config property
and use the configured value instead: @Scheduled(cron = "{myservice.check.cron.expr}")
.
public abstract String every
The value is parsed with Duration.parse(CharSequence)
. However, if an expression starts with a digit, "PT" prefix
is added automatically, so for example, 15m
can be used instead of PT15M
and is parsed as "15 minutes".
Note that the absolute value of the value is always used.
If the value starts with "{" and ends with "}" the scheduler attempts to find a corresponding config property
and use the configured value instead: @Scheduled(every = "{myservice.check.every.expr}")
.
PnDTnHnMn.nS
public abstract long delay
By default, the trigger starts when registered.
public abstract String delayed
delay()
. If delay()
is
set to a value greater then zero the value of delayed()
is ignored.
The value is parsed with Duration.parse(CharSequence)
. However, if an expression starts with a digit, "PT" prefix
is added automatically, so for example, 15s
can be used instead of PT15S
and is parsed as "15 seconds".
Note that the absolute value of the value is always used.
If the value starts with "{" and ends with "}" the scheduler attempts to find a corresponding config property
and use the configured value instead: @Scheduled(delayed = "{myservice.delayed}")
.
PnDTnHnMn.nS
public abstract Scheduled.ConcurrentExecution concurrentExecution
Copyright © 2020 JBoss by Red Hat. All rights reserved.