Removing Jobs

Currently we have 3 available methods in queue class:

Drain

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

import { Queue } from 'bullmq';

const queue = new Queue('paint');

await queue.drain();

You can also drain delayed jobs by setting the delayed parameter:

import { Queue } from 'bullmq';

const queue = new Queue('paint');

// Also drain delayed jobs
await queue.drain(true);
circle-exclamation
circle-exclamation

Clean

Removes jobs in a specific state, but keeps jobs within a certain grace period.

Obliterate

Completely obliterates a queue and all of its contents.

For more advanced scenarios where you need to force obliteration even with active jobs:

circle-exclamation

Read more:

Last updated

Was this helpful?