Skip to main content

Overview

When jobs are added to a queue, they transition through different states during their lifecycle. BullMQ provides methods to retrieve information and jobs from these various states.
Diagram of the lifecycle of a BullMQ job in the queue

Job Counts

Get the number of jobs in specific statuses:

Available Job States

From the Job class documentation:
  • completed - Jobs that have finished successfully
  • failed - Jobs that have failed after all retry attempts
  • delayed - Jobs waiting for their delay time to expire
  • active - Jobs currently being processed
  • wait - Jobs waiting to be processed
  • waiting-children - Jobs waiting for child jobs to complete
  • prioritized - Jobs with priority > 0 waiting to be processed
  • paused - Jobs in a paused queue
  • repeat - Repeatable job configurations

Get Jobs

Retrieve jobs with pagination:
Parameters:
  • types - Array of job states to retrieve
  • start - Starting index (0-based)
  • end - Ending index
  • asc - If true, returns oldest first; if false, returns newest first

Get Jobs by State

BullMQ provides convenience methods for specific states:

Job State Checks

From src/classes/job.ts:971-1008:

Get Current State

From src/classes/job.ts:1030:
Example usage:

Get Job by ID

Retrieve a specific job by its ID:
From src/classes/job.ts:470:

Get Counts per Priority

For prioritized jobs, get counts for specific priority levels:

Pagination Example

Retrieve all jobs in batches:

Common Patterns

Track queue statistics:
Retrieve and analyze failed jobs:
Track a specific job’s progress:

Read More

Get Job Counts

getJobCounts API Reference

Get Jobs

getJobs API Reference

Job State

getState API Reference

From ID

Job.fromId API Reference