Scheduler Service

Canvas provides an independently working ancillary service called Scheduler where you can program any job to execute automatically at scheduled intervals by invoking the scheduler service. For example, you can configure the scheduler to carry out a task like fetching alerts from staging area and delivering those to the recipients at a given time.

To schedule a job, you have to hit the scheduler endpoint with appropriate payload with URL or service endpoint that you want to invoke from the scheduler and then specify the scheduling details such as job group, job name, cronexpression etc.

A cronexpression is a 6 or 7-digit expression that represents a schedule. It takes the following format and you can schedule any job by specifying this expression accordingly in the payload.

<seconds> <minutes> <hours> <days of month> <months> <days of week> <years>

Refer the following link to generate your cronexpression.

https://crontab.guru/  

For example,

ExampleDescription
0 0 0 * * *Indicates a daily schedule.
0 0 12 * * ?Indicates a daily 12 PM schedule.
0 15 10 * * ? 2019Indicates a daily 10:15 AM schedule in the year 2019.


Sample URLs for GET and POST calls:


The URLs to create a job and fetch details of a job are as follows:

To create a job:                            http://localhost:8080/CTScheduler/rest/schedule/subscribe  

To fetch job and its details:          http://localhost:8080/CTScheduler/rest/schedule/getjob


Sample payload to create a job with two triggers:


Refer the following sample payload to create a job using scheduler. The sample job invokes the Google website ­­­­every two hours and every minute through two triggers respectively.

Note: You can create any number of jobs to be scheduled by specifying the job list with the respective schedule time one below the other in the payload.

{

  "jobgroup": "Google",

  "jobname": "InvokeGoogle",

  "callbackdetail":

       {
              "endpoint": "http://www.google.com",

              "servicetype": "GET",

              "payload": "{}"

       },

  "trigger":

       [{

              "triggergroup": "trigger1",

              "triggername": "triggername1",

              "cronexpression": "0 */2 * ? * *"

       },

       {

              "triggergroup": "trigger2",

              "triggername": "triggername2",

              "cronexpression": "0 0 * ? * *"

       }]

}

In the sample payload,

KeyDescription
jobgroupSpecify the user-defined job category.
jobnameSpecify the user-defined job name.
endpointEnter the URL or service endpoint to be invoked.
servicetypeSpecify the service type; GET/POST.
payloadPass the request data if required.
triggergroupSpecify the user-defined trigger group for the specific schedule.
triggernameSpecify the user-defined trigger name for the specific schedule.
cronexpressionEnter the 6-digit string to represent your schedule.