BullMQ
Search…
Adding bulks
Sometimes it is necessary to add a complete bulk of jobs atomically. For example, there could be a requirement that all the jobs must be placed in the queue or none of them. Also, adding a bulk of jobs can be faster since it reduces the roundtrips to Redis:
1
import { Queue } from 'bullmq';
2
3
const queue = new Queue('paint');
4
5
const jobs = await queue.addBulk([
6
{ name, data: { paint: 'car' } },
7
{ name, data: { paint: 'house' } },
8
{ name, data: { paint: 'boat' } },
9
]);
Copied!
This call can only succeed or fail, and all or none of the jobs will be added.
Copy link