Skip to main content

Overview

The JobScheduler class is used for managing repeatable jobs. It allows you to create, update, and remove job schedulers that automatically create jobs at specified intervals.

Constructor

string
required
The name of the queue
RepeatBaseOptions
required
Configuration options
The JobScheduler is typically accessed through the Queue.jobScheduler property rather than instantiated directly.

Example

Methods

upsertJobScheduler

Creates or updates a job scheduler.
string
required
Unique identifier for the job scheduler
RepeatOptions
required
Repeat configuration options
string
required
Name for jobs created by this scheduler
any
required
Data for jobs created by this scheduler
JobSchedulerTemplateOptions
required
Job options template
boolean
required
Whether to override existing scheduler
string
Optional producer identifier

getScheduler

Retrieves a job scheduler by ID.
string
required
The job scheduler ID
JobSchedulerJson | undefined
The job scheduler data or undefined if not found

getJobSchedulers

Gets all job schedulers.
number
default:"0"
Offset of first scheduler to return
number
default:"-1"
Offset of last scheduler to return
boolean
default:"false"
Return in ascending order by next execution time

getSchedulersCount

Gets the number of job schedulers.

removeJobScheduler

Removes a job scheduler.
string
required
The identifier of the job scheduler to remove
number
Number of removed schedulers (0 or 1)

RepeatOptions

JobSchedulerJson

Examples

Cron-based Scheduler

Interval-based Scheduler

Limited Iterations

With Start and End Dates