尚未收集仓库信息。
尚未检测到更新。GitHub 发布版本后会显示在这里。
BullMQ - Message Queue and Batch processing for NodeJS, Python, .NET, Elixir, Rust and PHP based on Redis or PostgreSQL
翻译准备中
正在加载完整 README。
查看完整 README ↗You can find tutorials and news in this blog: https://blog.taskforce.sh/
BullMQ is available natively in multiple languages:
npm install bullmq)python/ directory (pip install bullmq)rust/ directory (cargo add bullmq-official --rename bullmq)elixir/ directory ({:bullmq, "~> x.x"})dotnet/ directory (dotnet add package BullMQ)php/ directoryFor other platforms, check out the BullMQ Proxy.
Supercharge your queues with a professional front end:
Sign up at Taskforce.sh
Some notable organizations using BullMQ:
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
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 | ✓ | ✓ | ✓ | ✓ |
Fork the repo, make some changes, submit a pull-request! Here is the contributing doc that has more details.
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.
| ✓ |
| 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 |