The schedule
property of a Schedulable component can be set in a variety of formats, which the Oracle Commerce Platform interprets through the PropertyEditor
that is defined for the Schedule
type.
The different types of Schedules can also be created programmatically by creating instances of RelativeSchedule
, PeriodicSchedule
, or CalendarSchedule
.
PeriodicSchedule/RelativeSchedule
You can set a schedule property to a PeriodicSchedule
and RelativeSchedule
alone or in combination:
PeriodicSchedule
specifies a task that occurs at regular intervals, in this format:schedule=every
integer
time-unit
[
with catch up
]
RelativeSchedule
specifies a time relative to the current time, in this format:schedule=in
integer
time-unit
You set time-unit
to one of the following:
msec
sec
seconds
min
minute
minutes
hour
hours
day
days
For example, the following schedule
property is set to a RelativeSchedule
that specifies to start a task in 30 seconds:
schedule=in 30 seconds
The next example shows a schedule
property set to a PeriodicSchedule
that specifies to run a task every 20 minutes:
schedule=every 20 minutes
Finally, the following example shows a schedule
property set to a PeriodicSchedule
and a RelativeSchedule
that specify to wait 20 minutes before running a task, then run the task every 10 seconds thereafter:
schedule=every 10 seconds in 20 minutes
with catch up
You can qualify a PeriodicSchedule
with the string with catch up
, which determines whether the PeriodicSchedule
tries to catch up on missed jobs. By default, the schedule executes without catch up. For example, you might schedule two seconds between jobs as follows
schedule=every 2 seconds
If a job occurs at 14:00, the next job should occur at 14:02. If the Scheduler cannot handle the job until 14:05—for example, the polling interval is greater than the period between jobs—the Scheduler schedules the next job to start at 14:06, so the jobs scheduled for 14:02 and 14:04 are missed.
By specifying with catch up
, you can force execution of the missed jobs:
schedule=every 2 seconds with catch up
Given this property setting, at the first opportunity—in this case,14:05—the Scheduler runs two jobs to compensate for the jobs missed at 14:02 and 14:04. It runs the next job as regularly scheduled at 14:06.
CalendarSchedule
A CalendarSchedule
schedules a task to run at designated points on the calendar. For example, you might schedule a task for 2:30am each Sunday, or a specific date such as January 1. The format for a CalendarSchedule
looks like this:
schedule=calendar
mos
dates
wkdays
mo-
occurs
hrs
mins
You set these parameters as follows:
Parameter | Values | Description |
---|---|---|
|
| The months when the task occurs, where |
|
| The days of the month when the task occurs |
|
| The days of the week when the task occurs, where |
|
| Occurrences of the specified |
|
| The hours of the day when the task occurs, where |
|
| The minutes of the hour when the task occurs. |
You can specify multiple values for each parameter in two ways:
Separate discrete values with commas. For example, to indicate May and August in the
mos
parameter:4,7
Indicate a range of values with a dash (wraparound is allowed).. For example, to indicate each day between Monday and Friday inclusive in the
wkdays
parameter:2-6
You can substitute the following characters for each parameter:
*
(asterisk) specifies all values for that parameter..
(period) specifies no values for that parameter.
Using the CalendarSchedule
, a task is performed if all of the following conditions are true:
The current month matches one of the month entries.
One of the following is true:
The current day of the month matches one of the date entries,
The current day of the week matches one of the
wkdays
entries and its occurrence in the month matches one of the occurrence in month entries.
The current hour matches one of the hour entries.
The current minute matches one of the minute entries.
The following table provides some examples:
CalendarSchedule S | Task Occurrence |
---|---|
| 1st and 15th of every month, 2:05pm |
| 1st and last Sunday of every month, 2:05pm |
| Every day in February at 1am and 1pm |
| Every Monday in June, every hour on the hour |
| Every day, between 9am-5pm on the half hour |
Backwards Compatibility in CalendarSchedules
Early versions of the Oracle Commerce Platform use a 5-field CalendarSchedule
. This 5-field format is still supported; a CalendarSchedule
with 5 fields is interpreted as having an mo-occurs
value of *.