@queue/bullmq (5.81.4)
Installation
@queue:registry=npm install @queue/bullmq@5.81.4"@queue/bullmq": "5.81.4"About this package
The fastest, most reliable, Redis-based distributed queue for Node.js, Python, Elixir, Rust, PHP, and more.
Carefully written for rock solid stability and atomicity.
Follow Us for *important* Bull/BullMQ/BullMQ-Pro news and updates!
🛠 Tutorials
You can find tutorials and news in this blog: https://blog.taskforce.sh/
News 🚀
🌐 Language agnostic BullMQ
BullMQ is available natively in multiple languages:
- Node.js / Bun — This repository (
npm install bullmq) - Python —
python/directory (pip install bullmq) - Rust —
rust/directory (cargo add bullmq) - Elixir —
elixir/directory ({:bullmq, "~> x.x"}) - PHP —
php/directory
For other platforms, check out the BullMQ Proxy.
BullMQ Kit
BullMQ Kit provides task-style APIs on top of BullMQ queues. Pass Redis connections the same way you do with BullMQ, including URL strings.
npm install @queue/bullmq
import { App, Context } from '@queue/bullmq/kit';
const app = new App({
connection: 'redis://127.0.0.1:6379',
});
const add = app.task(
{
name: 'math.add',
context: true,
concurrency: 4,
retries: 2,
},
async (ctx: Context, left: number, right: number): Promise<number> => {
await ctx.setProgress(50);
await ctx.log(`Adding ${left} and ${right}`);
return left + right;
},
);
const multiply = app.task({ name: 'math.multiply' }, async (value: number) => {
const sum = await add(value, 10);
return sum * 2;
});
await app.connect();
const run = await multiply.start(5);
console.log(await run.result());
await app.close();
Producer-only clients can call a task registered by another process:
import { App } from '@queue/bullmq/kit';
const app = new App({
connection: 'redis://127.0.0.1:6379',
});
const add =
app.taskRef<(left: number, right: number) => Promise<number>>('math.add');
await app.connect();
console.log(await add(10, 20));
await app.close();
Official FrontEnd
Supercharge your queues with a professional front end:
- Get a complete overview of all your queues.
- Inspect jobs, search, retry, or promote delayed jobs.
- Metrics and statistics.
- and many more features.
Sign up at Taskforce.sh
🚀 Sponsors 🚀
|
|
Dragonfly is a new Redis™ drop-in replacement that is fully compatible with BullMQ and brings some important advantages over Redis™ such as massive better performance by utilizing all CPU cores available and faster and more memory efficient data structures. Read more here on how to use it with BullMQ. |
Used by
Some notable organizations using BullMQ:
|
|
|
|
|
|
|
|
|
The gist
Install:
$ yarn add bullmq
If you use the node-redis adapter (createNodeRedisClient), install redis v5 or newer (redis >= 5.0.0).
If you use the Valkey Glide adapter (createValkeyGlideClient), install @valkey/valkey-glide.
Add jobs to the queue:
import { Queue } from 'bullmq';
const queue = new Queue('Paint');
queue.add('cars', { color: 'blue' });
Process the jobs in your workers:
import { Worker } from 'bullmq';
const worker = new Worker('Paint', async job => {
if (job.name === 'cars') {
await paintCar(job.data.color);
}
});
Listen to jobs for completion:
import { QueueEvents } from 'bullmq';
const queueEvents = new QueueEvents('Paint');
queueEvents.on('completed', ({ jobId }) => {
console.log('done painting');
});
queueEvents.on(
'failed',
({ jobId, failedReason }: { jobId: string; failedReason: string }) => {
console.error('error painting', failedReason);
},
);
Adds jobs with parent-child relationship:
import { FlowProducer } from 'bullmq';
const flow = new FlowProducer();
const originalTree = await flow.add({
name: 'root-job',
queueName: 'topQueueName',
data: {},
children: [
{
name: 'child-job',
data: { idx: 0, foo: 'bar' },
queueName: 'childrenQueueName',
children: [
{
name: 'grandchild-job',
data: { idx: 1, foo: 'bah' },
queueName: 'grandChildrenQueueName',
},
{
name: 'grandchild-job',
data: { idx: 2, foo: 'baz' },
queueName: 'grandChildrenQueueName',
},
],
},
{
name: 'child-job',
data: { idx: 3, foo: 'foo' },
queueName: 'childrenQueueName',
},
],
});
This is just scratching the surface, check all the features and more in the official documentation
Feature Comparison
Since there are a few job queue solutions, here is a table comparing them:
| Feature | BullMQ-Pro | BullMQ | Bull | Kue | Bee | Agenda |
|---|---|---|---|---|---|---|
| Backend | redis | redis | redis | redis | redis | mongo |
| Observables | ✓ | |||||
| Group Rate Limit | ✓ | |||||
| Group Support | ✓ | |||||
| Batches Support | ✓ | |||||
| Parent/Child Dependencies | ✓ | ✓ | ||||
| Deduplication (Debouncing) | ✓ | ✓ | ✓ | |||
| Deduplication (Throttling) | ✓ | ✓ | ✓ | |||
| Priorities | ✓ | ✓ | ✓ | ✓ | ✓ | |
| Concurrency | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| Delayed jobs | ✓ | ✓ | ✓ | ✓ | ✓ | |
| Global events | ✓ | ✓ | ✓ | ✓ | ||
| Rate Limiter | ✓ | ✓ | ✓ | |||
| Pause/Resume | ✓ | ✓ | ✓ | ✓ | ||
| Sandboxed worker | ✓ | ✓ | ✓ | |||
| Repeatable jobs | ✓ | ✓ | ✓ | ✓ | ||
| Atomic ops | ✓ | ✓ | ✓ | ✓ | ||
| Persistence | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |
| UI | ✓ | ✓ | ✓ | ✓ | ✓ | |
| Optimized for | Jobs / Messages | Jobs / Messages | Jobs / Messages | Jobs | Messages | Jobs |
Contributing
Fork the repo, make some changes, submit a pull-request! Here is the contributing doc that has more details.
Thanks
Thanks for all the contributors that made this library possible, also a special mention to Leon van Kammen that kindly donated his npm bullmq repo.
Dependencies
Dependencies
| ID | Version |
|---|---|
| cron-parser | 4.9.0 |
| ioredis | 5.11.1 |
| msgpackr | 2.0.4 |
| node-abort-controller | 3.1.1 |
| semver | 7.8.5 |
| tslib | 2.8.1 |
Development Dependencies
| ID | Version |
|---|---|
| @commitlint/cli | 21.2.1 |
| @commitlint/config-conventional | 21.2.0 |
| @semantic-release/changelog | 6.0.3 |
| @semantic-release/commit-analyzer | 13.0.1 |
| @semantic-release/exec | 7.1.0 |
| @semantic-release/git | 10.0.1 |
| @semantic-release/github | 12.0.9 |
| @semantic-release/npm | 13.1.5 |
| @semantic-release/release-notes-generator | 14.1.1 |
| @types/lodash.defaults | 4.2.9 |
| @types/lodash.isarguments | 3.1.9 |
| @types/msgpack | 0.0.34 |
| @types/node | 24.13.3 |
| @types/semver | 7.7.1 |
| @types/sinon | 22.0.0 |
| @typescript-eslint/eslint-plugin | 8.64.0 |
| @typescript-eslint/parser | 8.64.0 |
| @vitest/coverage-v8 | 4.1.10 |
| coveralls-next | 6.0.2 |
| cpx2 | 9.0.0 |
| eslint | 9.39.5 |
| eslint-config-prettier | 8.10.2 |
| eslint-plugin-prettier | 4.2.5 |
| eslint-plugin-promise | 7.3.0 |
| eslint-plugin-tsdoc | 0.5.2 |
| fast-glob | 3.3.3 |
| globals | 17.7.0 |
| husky | 9.1.7 |
| lint-staged | 17.1.0 |
| madge | 8.0.0 |
| minimatch | 10.2.5 |
| moment | 2.30.1 |
| prettier | 3.9.5 |
| pretty-quick | 4.2.2 |
| progress | 2.0.3 |
| redis | 5.12.1 |
| rimraf | 6.1.3 |
| rrule | 2.8.1 |
| semantic-release | 25.0.8 |
| sinon | 21.1.2 |
| test-console | 2.0.0 |
| ts-node | 10.9.2 |
| typedoc | 0.28.20 |
| typescript | 5.9.3 |
| vitest | 4.1.10 |
Peer Dependencies
| ID | Version |
|---|---|
| redis | >=5.0.0 |
