Configure Schedules
To schedule tasks and events, select Configure > Schedules > Add Schedule in the Admin UI, or create a schedule configuration.
By convention, IDM uses file names of the form schedule-schedule-name.json
, where schedule-name is a logical name for the scheduled operation, for example, schedule-reconcile_systemCsvAccounts_managedUser.json
. There are several example schedule configuration files in the openidm/samples/example-configurations/schedules
directory.
Each schedule configuration has the following format:
{ "enabled" : boolean, "persisted" : boolean, "recoverable" : boolean, "concurrentExecution" : boolean, "type" : "simple | cron", "repeatInterval" : (optional) integer, "repeatCount" : (optional) integer, "startTime" : "(optional) time", "endTime" : "(optional) time", "schedule" : "cron expression", "misfirePolicy" : "optional, string", "invokeService" : "service identifier", "invokeContext" : "service specific context info", "invokeLogLevel" : "(optional) level" }
The schedule configuration properties are defined as follows:
enabled
Set to
true
to enable the schedule. When this property isfalse
, IDM considers the schedule configuration dormant, and does not allow it to be triggered or launched.If you want to retain a schedule configuration, but do not want it used, set
enabled
tofalse
for task and event schedulers, instead of changing the configuration or cron expressions.persisted
(optional)Specifies whether the schedule state should be persisted or stored only in RAM. Boolean (
true
orfalse
),false
by default.In a clustered environment, this property must be set to
true
to have the schedule fire only once across the cluster. For more information, see "Configure Persistent Schedules".Note
If the schedule is stored only in RAM, the schedule will be lost when IDM is restarted.
recoverable
(optional)Specifies whether jobs that have failed mid-execution (as a result of a JVM crash or otherwise unexpected termination) should be recovered. Boolean (
true
orfalse
),false
by default.concurrentExecution
Specifies whether multiple instances of the same schedule can run concurrently. Boolean (
true
orfalse
),false
by default. Multiple instances of the same schedule cannot run concurrently by default. This setting prevents a new scheduled task from being launched before the same previously launched task has completed. For example, under normal circumstances you would want a liveSync operation to complete before the same operation was launched again. To enable multiple schedules to run concurrently, set this parameter totrue
. The behavior of missed scheduled tasks is governed by themisfirePolicy
.type
The trigger type, either
simple
orcron
.To decide which trigger type to use, see the Quartz documentation on SimpleTriggers and CronTriggers.
repeatCount
Used only for simple triggers (
"type" : "simple"
).The number of times the schedule must be repeated. The repeat count can be zero, a positive integer, or -1. A value of -1 indicates that the schedule should repeat indefinitely.
If you do not specify a repeat count, the value defaults to -1.
repeatInterval
Used only for simple triggers (
"type" : "simple"
).Specifies the interval, in milliseconds, between trigger firings. The repeat interval must be zero or a positive long value. If you set the repeat interval to zero, the scheduler will trigger
repeatCount
firings concurrently (or as close to concurrently as possible).If you do not specify a repeat interval, the value defaults to 0.
startTime
(optional)This parameter starts the schedule at some time in the future. If the parameter is omitted, empty, or set to a time in the past, the task or event is scheduled to start immediately.
Use ISO 8601 format to specify times and dates (
yyyy-MM-dd'T'HH:mm:ss
).To specify a time zone, include the time zone at the end of the
startTime
, in the format+|-hh:mm
, for example2017-10-31T15:53:00+05:00
. If you specify both astartTime
and anendTime
, they must have the same time zone.endTime
(optional)Specifies when the schedule must end, in ISO 8601 format (
yyyy-MM-dd'T'HH:mm:ss+|-hh:mm
.schedule
Used only for cron triggers (
"type" : "cron"
).Takes cron expression syntax. For more information, see the CronTrigger Tutorial and Lesson 6: CronTrigger.
misfirePolicy
For persistent schedules, this optional parameter specifies the behavior if the scheduled task is missed, for some reason. Possible values are as follows:
fireAndProceed
. The first run of a missed schedule is immediately launched when the server is back online. Subsequent runs are discarded. After this, the normal schedule is resumed.doNothing
. All missed schedules are discarded and the normal schedule is resumed when the server is back online.
invokeService
Defines the type of scheduled event or action. The value of this parameter can be one of the following:
sync
for reconciliationprovisioner
for liveSyncscript
to call some other scheduled operation defined in a scripttaskScanner
to define a scheduled task that queries a set of objects. For more information, see Scan Data to Trigger Tasks.
invokeContext
Specifies contextual information, depending on the type of scheduled event (the value of the
invokeService
parameter).The following example invokes reconciliation:
{ "invokeService": "sync", "invokeContext": { "action": "reconcile", "mapping": "systemLdapAccount_managedUser" } }
The following example invokes a liveSync operation:
{ "invokeService": "provisioner", "invokeContext": { "action": "liveSync", "source": "system/ldap/__ACCOUNT__" } }
For scheduled liveSync tasks, the
source
property follows IDM's convention for a pointer to an external resource object and takes the formsystem/resource-name/object-type
.The following example invokes a script, which prints the node ID performing the scheduled job and the time to the console. A similar sample schedule is provided in
schedule-script.json
in the/path/to/openidm/samples/example-configurations/schedules
directory.{ "enabled" : true, "type": "simple", "repeatInterval": 3600000, "persisted" : true, "concurrentExecution" : false, "invokeService": "script", "invokeContext": { "script" : { "type" : "text/javascript", "source" : "java.lang.System.out.println('Job executing on ' + identityServer.getProperty('openidm.node.id') + ' at: ' + java.lang.System.currentTimeMillis());" } } }
Note that these are sample configurations only. Your own schedule configuration will differ according to your specific requirements.
invokeLogLevel
(optional)Specifies the level at which the invocation will be logged. Particularly for schedules that run very frequently, such as liveSync, the scheduled task can generate significant output to the log file, and you should adjust the log level accordingly. The default schedule log level is
info
. The value can be set to any one of the SLF4J log levels:trace
debug
info
warn
error
fatal