Scheduled Job - Job Definition
Overview
This section shows how to create and manage Job Definition
for the Scheduled Job
application.
Steps
Job Definition
- Right click on the
scheduled-job-project
project and select New → Scheduled Job. - Enter
log.job
for the name of the Scheduled Job. - Right click on
log.job
and select Open With → Code Editor. -
Replace the content with the following definition:
{ "expression": "0/10 * * * * ?", "group": "defined", "handler": "scheduled-job-project/handler.mjs", "description": "Scheduled Log Job", "parameters": [ { "name": "severity", "type": "choice", "defaultValue": "", "choices": "Info,Warning,Error", "description": "The log severity" }, { "name": "message", "type": "string", "defaultValue": "", "description": "The log message" } ] }
-
Double click on
log.job
to open it with theJob Editor
.
Save & Publish
Saving the file will trigger a Publish
action, that would schedule the job. As defined by the expression (0/10 * * * * ?
), the job handler would be executed each 10 seconds and data would be insterted into the LOG_EVENTS
table.
Log Events Data
- Navigate to the
Database Perspective
to check that there are new records in theLOG_EVENTS
table. -
You can notice in the
LOG_TIMESTAMP
column that the last records are 10 seconds apart each.
Manage Jobs
- Navigate to the
Jobs Perspective
to see a list of the Scheduled Jobs on the instance. -
Click on the
Enable/Disable
icon to stop thelog
Scheduled Job. -
Navigate to the
Database Perspective
to check that there are no new records in theLOG_EVENTS
table after the job was disabled. - Go back to the
Jobs Perspective
. -
Click on the
Trigger
icon and then on theTrigger
button to start newJob Execution
.Force Trigger
This action would instantly trigger the
Job Handler
without respecting theJob Schedule Expression
or whether theJob Schedule
is enabled or disabled. -
Navigate back to the
Database Perspective
to check that there was a new record added in theLOG_EVENTS
table after the job was disabled.
Summary
Tutorial Completed
After completing all steps in this tutorial, you would:
- Have
Scheduled Job
. - New records in the
LOG_EVENTS
table. - Experience with the
Jobs Perspective
.
Note: The complete content of the Scheduled Job tutorial is available at: https://github.com/dirigiblelabs/tutorial-scheduled-job-project