Job Scheduling

◷ Reading Time: 15 minutes

Introduction

Use Jobs and Job Scheduling to run your services seamlessly and concurrently using different agents.

For example, you can create jobs if you want to automatically do a few tasks concurrently such as:

  • Check an exchange rate every day at 8 AM and save it to an Excel file.
  • Check stock market rates every day at 8 AM and save it to an Excel file.

To schedule a job successfully requires three components:

  1. Service – this is where the business logic is handled.
  2. Job – the definition of when to run the service.
  3. Agent – the node that hosts the service and job.

Set up the Service to be run in the Job

1. Available services can be viewed at Execution Server > Services

Workbench Services landing page shows all uploaded services and related details.

2. Click on Edit under Actions menu of any specific service

Workbench services Actions menu dropdown showing Edit highlighted

3. Service details can be reviewed in the edit view under the General tab. These details are required to create a job.

  • Title
  • Key

And also, the service should be enabled

Workbench Services edit view for a specific service highlighting the Title and key fields and the Status checkboox

Set up the Job and Job schedule

1. Once you know which service you want to run, the next step is to create a job. For that, go to, Execution Server --> Jobs --> New Job

Workbench Jobs landing view showing the new job button higlighted

General tab

2. Change the settings under the General tab. Following is description of the settings:

Information

  • Name: Name of the job
  • Description: A brief description to describe the job

Activity

  • Enables: Make the job available to run or disable
  • Reentrant: Run multiple invocations
  • Batch Job: Multiple requests to a Service can be batched to one job instance. For creating and managing these Jobs see our article on Batch Jobs.
  • Timeout (seconds): *Requires a positive integer value. This defines the timeout duration a job instance will stay running when agent(s) are unresponsive. Once this duration is reached, if the Agent(s) are still unresponsive, the message will be Abandoned.

Activation

  • Effective From and Expires At: The Job Schedule specifying the start and end time of the job

Recurring

  • Cron: If it is an ongoing job, how often it should run (See [Cron] for more information on how to assign Cron.

The Cron supports the below specification:

Field name Allowed values Allowed special characters
Minutes 0-59 * , – /
Hours 0-23 * , – /
Day of month 1-31 * , – / ? L W
Month 1-12 or JAN-DEC * , – /
Day of week 0-6 or SUN-SAT * , – / ? L #
Year 0001–9999 * , – /
Workbench Job scheduling cron editor

Service tab

3. Change setting under the Service tab

Package

  • Identifier: Package Identifier
  • Version: Package version

Service

  • Name: Name of the service
  • Version: Version of the service
  • Key: Key of the service
  • Version Strategy: Use Latest/ Earliest

Inputs

  • Parameters: If there is an input JSON object, add it here. If using Batch job, enter multiple JSON objects as an array for the input.
Service details of a specific job in Workbench job scheduling

4. Click Save.

Details view of individual Job scheduling in Workbench. The save job button is highlighted

5. Activate the job if it is inactive.

Workbench job scheduling landing view showing a tabulated list of all jobs. The Status toggle is highlighted

Set up an Agent to run a Job

  • To view the existing agents, go to,
Administration --> Agents
Workbench Agent landing view showing details of the registered Agents in tabulated form
Workbench Agent landing view showing details of the registered Agents in tabulated form. the Actions menu is open and Edit is selected
  • Click Edit under Action to assign the agents to jobs
  • An agent is made compatible with Jobs and Services via the relevant tabs in edit view

Address

  • Name: Name of the agent
  • Is Active: Enable or disable the agent
  • Description: Role description
  • Host Url: Agent’s hosted URL
Workbench Agent edit view with the General tab selected and showing details of a registered Agent

Jobs tab

Distributed Scheduled Jobs

  • Allow Agent to run Jobs: Change the ability of the agent to run a job
  • Capacity: How many jobs the agent should run concurrently
Workbench Agent edit view with the Jobs tab selected showing the Agent is not configured for any jobs

Jobs

  • Compatible with all Jobs: Allows the Agent to run any jobs
Workbench Agent edit view with the Jobs tab selected showing the Agent is configured to run jobs

If the Agent is being dedicated to one or several Jobs, leave Compatible with all Jobs unchecked and select the individual Jobs to be assigned to the Agent.

Workbench Agent edit view with the Jobs tab selected showing the Agent is configured to run jobs and a specific job selected

View Job Logs

Job information including job executing times, running services, requests, responses, and exceptions of the job can be viewed under Logs.

Go to Execution Server --> Jobs and under Actions menu of a Job, select Logs. You will navigate to the logs of the selected job.

For full details on Job logs including viewing, filtering and pagination see our Resource Hub article on Job Logs.

Workbench job scheduling landing view showing a tabulated list of all jobs. The Actions dropdown is open and Logs are highlighted

Job Instance status details

Queued – When a job instance is placed in the queue for processing.

Completed Successfully – When a job instance is completed without error and result is successful.

Completed with errors – When a job instance is completed but has error in the result. This could be due to errors in the service or request.

Check the View Results option under the Action menu of the job instance for further details.

Retry with Errors – A parent job instance that has errored in a retry attempt.

Check the View Results option under the Action menu of the job instance for further details.

Retry Successfully – A parent job instance that was completed successfully in a retry attempt.

Abandoned – When a running job instance is terminated without completion due to an unresponsive agent.

Job Information

Click on Job Information to view further details of the job.

Detail view of the Job Information button in Workbench job scheduling logs view

This displays the Job information details for the selected log of Job Instances.

If the Job is a Batch Job, this will also display the progress of the batch including:

  • The percentage executed
  • The number of instances executed versus the total Instances of the batch
Job Information expanded view showing the job Progress and Job details

To see the request, response, and exceptions logs of each execution, click on View Results.

Workbench job scheduling logs view showing a tabulated list of all processed Job instances. The Actions menu is open with View Results selected

The Job Instance details modal will display and there are three tabs, Request, showing the JSON request object for the job, Response, showing the JSON response object and Exception giving details of any Exception for a Job Instance.

Job Instance Details modal with the Request tab active showing the JSON request object for the job instance
Job Instance Details modal with the Response tab active showing the JSON response object for the job instance

Delete a Job Instance

To delete a job instance, select Delete from the Actions menu of the instance in the Job log list.

Detail view of the Actions menu open and Delete log selected for Workbench job scheduling logs view

Retry Job Instance

Any Job Instances showing a status of Completed with Errors or Abandoned can be requeued for retry execution.

Note: Although the process to retry is the same for these two status. There is a subtle difference in how they are displayed in the Logs view.

In the Job log List view, select “Retry” from the Actions menu of a particular Job Instance that has Completed With Errors or Abandoned Status.

Job Log showing the Job instances. The Actions menu is open and retry is selected for a job instance that has Completed with Errors

This will open the retry modal where you can modify the request JSON. Do this if the failure was due to an issue with the request format or content.

Selecting Submit will initiate a retry of the original Job Instance including any changes to the request object.

If the Retry succeeds to execute without error the status of the Job Instance will change to Retry Successful and the icon at the far left of the Job Instance will change from a red circle, white cross to a green circle, white tick.

Once a retry has been attempted an arrow will appear on the far left of the Instance in the list view. If you select the arrow icon it will expand a view of all child Retry instances, selecting the arrow icon again to collapse the view.

All child retry instances will be assigned the Completed Successfully or Completed with Errors status. The original failed parent instance will have the status Retry Successfully or Retry with Errors, depending on the result of the retried child instance.

In the Abandoned case, the original parent instance will maintain the Abandoned status. This ensures that instance to still appear under the Abandoned filter.

For any retry child instance, the details of the retry Job Instance can be viewed by selecting View Details from the Actions menu.

A retry child Job Instance cannot be deleted, all child retry instances are removed if the parent Job instance is deleted.

Job instance log view showing the retry children expanded and the Show details Action menu item selected

In the case of a failed retry, the parent Job Instance Status will change to Retry With Errors and the red circle with a white cross icon will remain. Similarly to above, select the arrow icon to expand the retry child view to see the retry instances.

Job instance log view showing the retry was Completed with Error and the child retry instances expanded. The parent Instance displays a status of Retry wih Errors.

A retry Instance cannot be retried itself, instead if a retry has also Completed with Errors the original parent instance can be retried again.

Troubleshooting

If your jobs are not starting or not running correctly, ensure the following.

  • The agent should have permission to run a job.
Trouble shooting details specifying to check if the Agent is configured to run jobs
  • Master and Agent should run as an Administrator.
Trouble shooting details specifying to check if the Agent and Master are set to Run as administrator
  • Both Agent and Job should be enabled.
Trouble shooting details specifying to check if the Job is enabled in the Workbench Jobs list view
Job is active
Trouble shooting details specifying to check if the Agent is enabled in the Workbench Agent list view
Agent is active
  • The IP address and port that the agent is listening on must match the URL set for the agent in the Workbench.
Trouble shooting details specifying to check the Agent IP address in the configurator
Trouble shooting details specifying to check the Agent IP address is the same as the configurator in the Agent Edit view

Updated on February 12, 2024

Was this article helpful?

Related Articles