Overview
The Queue class provides methods to add jobs to a queue and perform high-level queue administration such as pausing or deleting queues.Constructor
string
required
The name of the queue
QueueOptions
Configuration options for the queue
Example
Methods
add
Adds a new job to the queue.string
required
Name of the job
any
required
Arbitrary data to append to the job
JobsOptions
Job options that affect how the job is processed
Job
The created job instance
addBulk
Adds an array of jobs to the queue atomically.Array
required
Array of job objects with name, data, and opts properties
Job[]
Array of created job instances
pause
Pauses the processing of this queue globally.resume
Resumes the processing of this queue globally.isPaused
Returns true if the queue is currently paused.getJob
Fetches a job by its ID.string
required
The job ID to fetch
getJobs
Returns jobs on the given statuses.JobType[]
Job statuses to retrieve (e.g., ‘waiting’, ‘active’, ‘completed’)
number
default:"0"
Zero-based index from where to start returning jobs
number
default:"-1"
Zero-based index where to stop returning jobs
boolean
default:"false"
If true, jobs will be returned in ascending order
getJobCounts
Returns the job counts for each type specified.clean
Cleans jobs from a queue within a certain grace period.number
required
The grace period in milliseconds
number
required
Max number of jobs to clean
string
default:"'completed'"
The type of job to clean: ‘completed’, ‘wait’, ‘active’, ‘paused’, ‘delayed’, or ‘failed’
drain
Drains the queue, removing all jobs that are waiting or delayed.boolean
default:"false"
If true, also clean delayed jobs
obliterate
Completely destroys the queue and all of its contents irreversibly.boolean
default:"false"
Force obliteration even with active jobs in the queue
number
default:"1000"
Maximum number of deleted keys per iteration
remove
Removes a job from the queue.string
required
The ID of the job to remove
boolean
default:"true"
Whether to remove child jobs
setGlobalConcurrency
Enables and sets global concurrency value.number
required
Maximum number of simultaneous jobs that workers can handle
removeGlobalConcurrency
Removes the global concurrency limit.setGlobalRateLimit
Enables and sets rate limit.number
required
Max number of jobs to process in the time period
number
required
Time in milliseconds for the rate limit period
removeGlobalRateLimit
Removes global rate limit.upsertJobScheduler
Upserts a job scheduler for creating jobs at intervals.string
required
Unique identifier for the job scheduler
RepeatOptions
required
Repeat configuration options
object
Template for jobs created by this scheduler
getJobSchedulers
Get all job schedulers.removeJobScheduler
Removes a job scheduler.close
Closes the queue instance.Events
The Queue class extends EventEmitter and emits the following events:waiting- A job has been added to the queueprogress- A job’s progress has been updatedcompleted- A job has completed successfullyfailed- A job has failedpaused- The queue has been pausedresumed- The queue has been resumedremoved- A job has been removedcleaned- Jobs have been cleaned from the queueerror- An error occurred
