@javax.ejb.Schedule: Difference between revisions
Jump to navigation
Jump to search
Line 32: | Line 32: | ||
* year | * year | ||
<blockquote style="background-color: Gold; border: solid thin Goldenrod;"> | |||
:<br>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.<br><br> | |||
</blockquote> | |||
The following example fires a timer every 20 seconds, continuously: | The following example fires a timer every 20 seconds, continuously: |
Revision as of 16:54, 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
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() {
...
}