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
The name of the queue
Configuration options for the queue
Example
Methods
add
Adds a new job to the queue.Name of the job
Arbitrary data to append to the job
Job options that affect how the job is processed
The created job instance
addBulk
Adds an array of jobs to the queue atomically.Array of job objects with name, data, and opts properties
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.The job ID to fetch
getJobs
Returns jobs on the given statuses.Job statuses to retrieve (e.g., ‘waiting’, ‘active’, ‘completed’)
Zero-based index from where to start returning jobs
Zero-based index where to stop returning jobs
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.The grace period in milliseconds
Max number of jobs to clean
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.If true, also clean delayed jobs
obliterate
Completely destroys the queue and all of its contents irreversibly.Force obliteration even with active jobs in the queue
Maximum number of deleted keys per iteration
remove
Removes a job from the queue.The ID of the job to remove
Whether to remove child jobs
setGlobalConcurrency
Enables and sets global concurrency value.Maximum number of simultaneous jobs that workers can handle
removeGlobalConcurrency
Removes the global concurrency limit.setGlobalRateLimit
Enables and sets rate limit.Max number of jobs to process in the time period
Time in milliseconds for the rate limit period
removeGlobalRateLimit
Removes global rate limit.upsertJobScheduler
Upserts a job scheduler for creating jobs at intervals.Unique identifier for the job scheduler
Repeat configuration options
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
