JobScheduler Service

The JobScheduler allows for the creation and management of jobs by adding these jobs to queue(s). A queue is created for a specific job that will be executed. Each queue has a _DoJob and _Error events that allows for the execution of the job. Multiple queues can be added to the scheduler.

Properties

Database Connection

  • Database Type: Where the Job Queues are to be stored
    • SQL Server : Store queue data in a MS SQL Server database
    • SQLite : Store queue data in a SQLite database
    • Memory : only store the queues in memory, queues will be lost when memory is cleared
  • Connection String: The database connection string required where tables will be created. These tables are responsible for storing job related data. A new schema is created for the required tables ([linx_jobscheduler]). Not required when memory is selected as the database type.

Note: Tables are only created on run, Linx requires permissions to alter/create database objects, as well as full access to created tables. Contact support@linx.software for the scripts to manually create or update the database.

Queues

You can add as many queues as required to the JobScheduler.

  • Name: Display name of a Queue
  • ID: ID that the queue is to be saved against. When this is changed, all existing jobs bound to this queue id will not be executed (they will remain in the database).
  • Data Type: What data type is to be passed into the job (input parameter)
  • Retry Strategy: When a job fails, what strategy must be followed to retry the job.
    • Number Of Times: The exact number of times a job is to be retried.
    • Seconds To Wait: How long to wait before the next retry in seconds. May not be exact when set to less than 15 seconds. It is advisable to set this time to more than 15 seconds for more control. This is due to the polling implementation.
    • Backoff Exponent: How long to wait between each retry (exponentially). It will indicate how long to wait (exponentially) between retries. The second retry will wait longer than the first retry, and the third retry will wait much longer. Set this to 1 if you do not want an exponential wait time.

Notes: A good idea will be to ensure that the process is idempotent (rerunnable) as the retry strategy will rerun the process completely. This will also apply in case there are any service interruptions.

  • Max Concurrency: The maximum number of jobs that can run at the same time. Must be 1 or more.
  • Batch size: The amount of jobs to be batched together. The execution will wait for a batch of this size before executing those jobs together.

Events and functions

Events and functions are created per queue. Events are executed by the service, however jobs must first be added to a queue in order for an event to execute anything.

Events

  • _DoJob: Job logic is to be placed in this event.
  • _Error: Error logic is placed here, what is to be done in case of an error. Note that Faults are logged per job, and can be retrieved with the _GetJob function.

Functions

_AddJob

Add a job to the queue.

Parameters:

  • Data: This is the data to pass in to the _DoJob event. It will depend on the selected input data type
  • Delay: Amount of time to wait before the job is executed
  • Reoccurring: A Cron that indicates the recursion of the Job. This Cron allows for the inclusion of seconds, for example: 0 */1 * * * * will execute the job every minute.

_CancelJob

Cancel a job from running. Note that only a job in the Wait status can be canceled.

Parameters:

  • Job ID: ID of the job to be cancelled.

_GetJobs

Get jobs on this queue.

Parameters:

  • Max results: Results will be returned in a page list containing a specified maximum number of records. This property is mandatory.
  • Page token: The page to be returned.
    • Set value to Null for first page
    • Set value to _GetJobs.NextPageToken to return the next page (from the function results)
    • Set value to _GetJobs.PreviousPageToken to return the previous page (from the function results)
  • Statuses: Return jobs with the specified status. Statuses include:
    • Wait
    • Active
    • Completed
    • Failed
    • Canceled

_GetJob

Get information pertaining to a specific Job.

Parameters:

  • Job ID: ID of the job that information must be retrieved of.