Skip to main content
BullMQ provides several methods for removing jobs from queues, from removing individual jobs to bulk cleanup operations.

Remove Individual Job

Remove a specific job by its ID, along with all its dependencies:

Method Signature

string
required
The ID of the job to remove
boolean
default:"true"
If true, also removes child jobs in flows. Set to false to keep child jobs.
Returns: 1 if the job was removed successfully, 0 if the job or any of its dependencies were locked.

Example

When a job is removed, a removed event is emitted by the queue.

Drain

Removes all jobs that are waiting or delayed, but not active, waiting-children, completed, or failed jobs.

Method Signature

boolean
default:"false"
If true, also removes delayed jobs

Examples

Parent Job Behavior

  • Parent jobs in the queue being drained will be kept in waiting-children status if they have pending children. If they have no pending children, they will be removed.
  • Parent jobs in other queues will stay in waiting-children if they have pending children elsewhere, or be moved to wait if all their children are gone.

Clean

Removes jobs in a specific state, keeping only jobs within a grace period. Similar to drain but more targeted.

Method Signature

number
required
Grace period in milliseconds. Jobs older than this will be removed.
number
required
Maximum number of jobs to clean
string
default:"completed"
The type of jobs to clean. Can be: completed, wait, waiting, active, paused, prioritized, delayed, or failed.
Returns: Array of deleted job IDs

Examples

The clean method triggers a cleaned event with the deleted job IDs and the job type.

Obliterate

Completely destroys a queue and all of its contents irreversibly. Use with extreme caution.

Method Signature

boolean
default:"false"
Use force: true to obliterate even with active jobs in the queue
number
default:"1000"
Maximum number of keys to delete per iteration

Examples

This operation is irreversible and will delete all queue data. The queue will be paused first. Parent jobs in other queues will either stay in waiting-children if they have pending children elsewhere, or be moved to wait.
This operation may be slow for very large queues as it must iterate over all jobs.

Specialized Removal Methods

Remove Deduplication Key

Removes a deduplication key, allowing duplicate jobs to be added again:

Remove Rate Limit Key

Removes the rate limit key, clearing any active rate limiting:

Remove Job Scheduler

Removes a job scheduler (repeatable job):

Practical Examples

Example 1: Periodic Cleanup

Example 2: Queue Reset

Example 3: Graceful Queue Deletion