A Job is a SQL or Nashorn JavaScript file that is executed at designated times. A job has a name that references the name of a textresource. It is possible to deploy a job as part of a module or by directly inserting it into the database. This can be done at runtime without a restart of the system (see below).
A job must reference a textresource that has the same name and type. The two supported values for type are
sql and script.
{
"jobs": {
"2c84fa53-f213-48cb-bc10-dd5d9fb09608": {
"name": "housekeeping",
"type": "sql",
"interval": "cron:15 */5 * * * ?",
"module": "simple-1.0.0"
}
},
"textresources": {
"e2ebe9fa-65da-4bf9-92c0-cc7916c9c040": {
"name": "houskeeping",
"type": "sql",
"method": "url",
"value": "classpath:/de/ecm4u/faw/module/simple/jobs/housekeeping-1.0.0.sql",
"module": "simple-1.0.0"
}
}
}
The JSON representation of a job has four properites:
name: The name of the job, must be equal to the name of a textresource.type: The type of of the job, must be sql or script (see below).interval: Either every minute, every hour, or a cron expression including seconds with the prefix cron:.module: The module version in which the job is included.A job with type sql mus reference a textresource with type sql. This textresource must contain SQL that
does not require any parameters.
Example (removes all transient queries that have not been executed):
delete from "query"
where
"persisted" is false
and
"created" < now() - interval '5 minutes'
;
A job with type script must reference a textresource with type script. This textresource must contain Javascript
with a single run() function.
Example:
function run() {
logger.info("Hello from foo.js!");
return {
message: "OK",
success: true
};
}
Jobs are stored in the table job. To create a job manually, insert a row into this table. The following columns
are required.
name: the name of the job, must be equal to the name of a textresourcetype: the type of the job, must be sql or scriptinterval: every minute, every hour, or a cron expression including seconds prefixed by cron:uuid: a UUIDAll other columns are set to default values.
To disable a job, set the enabled column to false. To enable it, set this column to true. To make this
change effetive, reload the jobs (see below).
Jobs using a cron expression can be created and enabled or disabled at runtime. This requires a HTTP POST request to
the admin port of the server (default 8093).
curl -X POST 'http://sbcs-host:8093/tasks/startjob?JOB_NAME=RegisterJobsJob'