Skip to main content

Overview

A Queue is the central data structure in BullMQ that holds jobs waiting to be processed. Queues are lightweight and can handle both small message-like jobs and larger long-running jobs.
When you instantiate a Queue, BullMQ creates or connects to an existing queue in Redis. Queues are persistent and survive application restarts.

Adding Jobs

The primary method for interacting with a queue is add(), which adds jobs to the queue:

Basic Job Addition

Job Options

Customize job behavior with options:

Bulk Operations

Add multiple jobs atomically for better performance:

Job Options Reference

JobsOptions Interface

Queue Management

Pausing and Resuming

Draining and Cleaning

Obliterate

Completely destroy a queue and all its data. This operation is irreversible.

Rate Limiting

Global Rate Limit

Limit the number of jobs processed across all workers:

Global Concurrency

Limit concurrent job processing globally:

Job Schedulers

Create recurring jobs with job schedulers:

Queue Events

Listen to queue-level events:

Retrieving Jobs

Get Individual Jobs

Get Job Counts

Get Jobs by State

Queue Metadata

TypeScript Support

Type-safe queues with generics:

Advanced Features

Deduplication

Prevent duplicate jobs based on a unique ID:

Job Retry

Retry all failed jobs:

Job Promotion

Promote delayed jobs to waiting:

Best Practices

Use Bulk Operations

When adding multiple jobs, use addBulk() for better performance through atomic operations.

Set Job TTL

Use removeOnComplete and removeOnFail to prevent Redis memory bloat.

Monitor Queue Health

Regularly check job counts and clean old jobs to maintain performance.

Handle Errors Gracefully

Always listen to the ‘error’ event to prevent unhandled exceptions.

Next Steps

Workers

Learn how to process jobs with workers

Jobs

Deep dive into job lifecycle and options

Events

Monitor queue activity with events