Jobs Scheduler

The jobs scheduler add-on allows developers to create Jobs and schedule them for execution using Triggers. The job scheduler API has been built leveraging the Quartz Job Scheduler (https://www.quartz-scheduler.org/). It has both a back-end ReST API and a front-end Angular client.

The code that executes when a job runs can be defined as a method of a Java class that implements the Quartz Scheduler’s Job interface and implements it’s execute method.

public class sampleJob implements Job {

    @Override
    public void execute(JobExecutionContext context) {
        JobKey key = context.getJobDetail().getKey();

        JobDataMap dataMap = context.getJobDetail().getJobDataMap();

        String jobValue = dataMap.getString("jobSays");

        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
    }
}

Back-end API

The API for the Scheduler and Triggers can be found at the following location https://api.getfastcode.com

Front-end UI

The Jobs Scheduler has four different screens - Jobs, Executing Jobs, Triggers, and Execution History. The functionality of each of these screens is described below:

Jobs

The jobs screen displays the list of jobs that have been created.

From this screen, we can create a new job by clicking the Add Job button.

The information to be specified for creating the job are as follows:

Name: The name of the job

Group: The name of the job group

Select Job Class: The name of the back-end Java Class that implements the Job interface

Durable: A job can be either durable or non-durable. If the job is non-durable, once it executes, it can no longer be re-used, whereas a durable job can be re-used for multiple executions.

Description: Description of the job

Job Data: Job Data is a Java Map to which you can key-value pairs. This map is then made available to the job instance when it executes.

Triggers

Triggers are used to trigger jobs on a schedule. There are various types of triggers, but the most common triggers are Simple Triggers and Cron Triggers. Once a trigger completes it's schedule of executing a job, it no longer is listed in the Triggers screen.

Creating a new Trigger

fastCode supports creating Simple Triggers and Cron Triggers from the front-end UI.

A simple trigger executes a job exactly once at a specific date and time, optionally followed by repeated execution at a specific interval. For example, trigger a job at exactly 11:23:54 AM EST on December 13, 2020 and then trigger it five more times, every ten seconds.

A cron trigger executes a job on a recurring calendar based schedule. For example, trigger a job every Sunday at 1AM EST.

In order to create a trigger, the following information needs to be provided:

Trigger Type: Select either a Simple Trigger or a CRON Trigger. The rest of the screen elements vary based on the type of trigger selected.

The section below discusses the screen elements for a Simple trigger.

Select a Job: Select the job that has been previously created from the Jobs screen

Job Name: The name of the job is automatically filled once you select a job

Job Group: The group of the job is automatically filled once you select a job

Trigger Details

Name: The name of the trigger

Group: The name of the trigger group

Start Date: The user's local date when the trigger fires

Start Time: The user's local time when the trigger fires

End Date: The user's local date after which triggers should not fire

End Time: The user's local time after which triggers should not fire

Repeat Interval: The time duration in seconds between trigger firings

Repeat Indefinitely: Whether or not the triggers need to repeat indefinitely for every repeat interval

Repeat Count: How many times the trigger should fire. This option is only shown if the Repeat Indefinitely setting is turned off.

Description: The description of the trigger

Job Data: Key value pairs that can be passed to the job during it's execution

Executing Jobs

This screen displays the list of jobs that are currently under active execution. Once a job completed execution, it disappears from this screen.

Execution History

This screen displays the history of execution of all jobs.