@javax.ejb.Schedule: Difference between revisions
Jump to navigation
Jump to search
Line 23: | Line 23: | ||
=Configuration= | =Configuration= | ||
The annotation is configured using a cron-like time expression | The annotation is configured using a cron-like time expression, using the following attributes: | ||
* second (if not specified, default is 0) | |||
* minute (if not specified, default is 0) | |||
* hour (if not specified, default is 0) | |||
* dayOfMonth | |||
* month | |||
* dayOfWeek | |||
* year | |||
{{Warn:If you intend to test a time firing every other few seconds, make sure to specify hour="*" and minute="*". If they are not specified, the default values are 0 and 0, respectively, which means your timer will start firing at midnight next day, for maximum a minute.}} | |||
The following example fires a timer every 20 seconds, continuously: | |||
<syntaxhighlight lang='java'> | |||
@Schedule(hour="*", minute="*", second = "0/20") | |||
public void fireEvery20SecsContinously() { | |||
... | |||
} | |||
</syntaxhighlight> |
Revision as of 16:52, 25 September 2017
External
Internal
Overview
Used by EJB to designate timeout callback methods that will be invoked by automatically-created timers.
Example:
@Schedule(hour="3", dayOfMonth="1", info="something")
public void toBeExecutedAt3AMOnTheFirstDayOfTheMonth() {
...
}
Configuration
The annotation is configured using a cron-like time expression, using the following attributes:
- second (if not specified, default is 0)
- minute (if not specified, default is 0)
- hour (if not specified, default is 0)
- dayOfMonth
- month
- dayOfWeek
- year
{{Warn:If you intend to test a time firing every other few seconds, make sure to specify hour="*" and minute="*". If they are not specified, the default values are 0 and 0, respectively, which means your timer will start firing at midnight next day, for maximum a minute.}}
The following example fires a timer every 20 seconds, continuously:
@Schedule(hour="*", minute="*", second = "0/20")
public void fireEvery20SecsContinously() {
...
}