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

name
string
required
The name of the queue
opts
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.
jobSchedulerId
string
required
Unique identifier for the job scheduler
repeatOpts
RepeatOptions
required
Repeat configuration options
jobName
string
required
Name for jobs created by this scheduler
jobData
any
required
Data for jobs created by this scheduler
opts
JobSchedulerTemplateOptions
required
Job options template
config.override
boolean
required
Whether to override existing scheduler
config.producerId
string
Optional producer identifier

getScheduler

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

getJobSchedulers

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

getSchedulersCount

Gets the number of job schedulers.

removeJobScheduler

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

RepeatOptions

JobSchedulerJson

Examples

Cron-based Scheduler

Interval-based Scheduler

Limited Iterations

With Start and End Dates