Annotation Type Scheduled
Runs this method of a bean on a schedule.
Exactly one of cron(), fixedRate() or fixedDelay() (or their String
forms) must be given. The method takes no arguments.
A literal cron expression is parsed by the build, which writes its fields
into the entry point as bit masks and refuses a malformed one: an expression
nobody noticed was wrong otherwise fires never, or every second. One that
reads configuration (${report.cron}) is parsed once at start-up instead.
The format is Spring's six fields -- second, minute, hour, day of month,
month, day of week -- plus the @yearly, @monthly, @weekly, @daily
and @hourly macros:
@Scheduled(cron = "0 */15 * * * MON-FRI")
public void refresh() { ... }
Several instances of one server each run every job. lock() makes a job run
on one of them at a time, through a row in the database.
-
Optional Element Summary
Optional ElementsModifier and TypeOptional ElementDescriptionA cron expression, or${key}to read one from configuration.The executor to run on.longMilliseconds between the end of one run and the start of the next.fixedDelay()as text, which may read configuration.longMilliseconds between the starts of consecutive runs.fixedRate()as text, which may read configuration.longMilliseconds before the first run of a fixed-rate or fixed-delay job.initialDelay()as text, which may read configuration.A lock name.longHow long a claimed lock is held at most, in milliseconds, so an instance that dies mid-run does not hold it for good.Which kind of thread runs it.The time zone the cron expression is read in: a zone ID such asEurope/Berlin, a fixed offset such as+02:00, orUTC.
-
Element Details
-
cron
-
zone
String zoneThe time zone the cron expression is read in: a zone ID such asEurope/Berlin, a fixed offset such as+02:00, orUTC. Empty means UTC, which is what a server should keep its clock in anyway.- Default:
""
-
fixedRate
long fixedRateMilliseconds between the starts of consecutive runs.- Default:
-1L
-
fixedDelay
long fixedDelayMilliseconds between the end of one run and the start of the next.- Default:
-1L
-
initialDelay
long initialDelayMilliseconds before the first run of a fixed-rate or fixed-delay job.- Default:
-1L
-
fixedRateString
-
fixedDelayString
-
initialDelayString
-
thread
-
executor
-
lock
String lockA lock name. When set, a run first claims the named row in thecn1_scheduler_locktable and is skipped if another instance holds it. Needs a database.- Default:
""
-
lockAtMostFor
long lockAtMostForHow long a claimed lock is held at most, in milliseconds, so an instance that dies mid-run does not hold it for good. Zero or less means ten minutes.- Default:
-1L
-