Annotation Type Scheduled
-
@Target(METHOD) @Retention(RUNTIME) @Repeatable(Schedules.class) public @interface Scheduled
Marks a business method to be automatically scheduled and invoked by the container.The target business method must be non-private and non-static.
The schedule is defined either by
cron()
or byevery()
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 returnvoid
and either declare no parameters or one parameter of typeScheduledExecution
.- Author:
- Martin Kouba
- See Also:
ScheduledExecution
-
-
Optional Element Summary
Optional Elements Modifier and Type Optional Element 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.
-
-
-
Element Detail
-
identity
String identity
Optionally defines a unique identifier for this job.If the value starts with "{" and ends with "}" the scheduler attempts to find a corresponding config property and use the configured value instead:
@Scheduled(identity = "{myservice.check.identity.expr}")
.If the value is not given, Quarkus will generate a unique id.
- Returns:
- the unique identity of the schedule
- Default:
- ""
-
-
-
cron
String cron
Defines a cron-like expression. For example "0 15 10 * * ?" fires at 10:15am every day.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}")
.- Returns:
- the cron-like expression
- Default:
- ""
-
-
-
every
String every
Defines a period between invocations.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 ofPT15M
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}")
.- Returns:
- the period expression based on the ISO-8601 duration format
PnDTnHnMn.nS
- Default:
- ""
-
-
-
delayed
String delayed
Defines a period after which the trigger should start. It's an alternative todelay()
. Ifdelay()
is set to a value greater then zero the value ofdelayed()
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 ofPT15S
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}")
.- Returns:
- the period expression based on the ISO-8601 duration format
PnDTnHnMn.nS
- Default:
- ""
-
-
-
concurrentExecution
Scheduled.ConcurrentExecution concurrentExecution
Specify the strategy to handle concurrent execution of a scheduled method. By default, a scheduled method can be executed concurrently.- Returns:
- the concurrent execution strategy
- Default:
- io.quarkus.scheduler.Scheduled.ConcurrentExecution.PROCEED
-
-