Skip to main content

Overview

The QueueEvents class is used for listening to global events emitted by a queue. This class requires a dedicated Redis connection.

Constructor

string
required
The name of the queue to listen to
QueueEventsOptions
Configuration options for queue events

Example

Methods

run

Manually starts the event consumption loop.
You only need to call this if you set autorun: false in the constructor options.

close

Stops consuming events and closes the Redis connection.

Events

The QueueEvents class extends EventEmitter and emits the following events:

added

Emitted when a job is created and added to the queue.
string
The unique identifier of the job
string
The name of the job
string
The event stream ID

active

Emitted when a job enters the active state.
string
The unique identifier of the job
string
The previous state of the job

completed

Emitted when a job has successfully completed.
string
The unique identifier of the job
any
The return value of the job (JSON parsed)
string
The previous state of the job

failed

Emitted when a job has failed.
string
The unique identifier of the job
string
The reason or message describing why the job failed
string
The previous state of the job

progress

Emitted when a job updates its progress.
string
The unique identifier of the job
number | object
The progress data

delayed

Emitted when a job is scheduled with a delay.
string
The unique identifier of the job
number
The delay duration in milliseconds

waiting

Emitted when a job enters the waiting state.

waiting-children

Emitted when a job is waiting for its children to complete.

removed

Emitted when a job is removed from the queue.

drained

Emitted when the queue has drained its waiting list.

paused

Emitted when the queue is paused.

resumed

Emitted when the queue is resumed.

stalled

Emitted when a job has stalled.

retries-exhausted

Emitted when a job has exhausted its retry attempts.

duplicated

Emitted when a job is not created because a job with the same ID already exists.

deduplicated

Emitted when a job is not added because a job with the same deduplication ID exists.

cleaned

Emitted when jobs are cleaned from the queue.

error

Emitted when an error occurs in the Redis backend.

Job-Specific Events

You can also listen to events for a specific job: