BullMQ
Search…
⌃K

Prioritized

Jobs can also include a priority option. Using priorities, job's processing order will be affected by the specified priority instead of following a FIFO or LIFO pattern.
Adding prioritized jobs is a slower operation than the other types of jobs, with a complexity O(n) relative to the number of jobs waiting in the Queue.
Note that the priorities go from 1 to MAX_INT, whereas a lower number is always a higher priority than higher numbers.
Jobs without a priority assigned will get the least priority.
import { Queue } from 'bullmq';
const myQueue = new Queue('Paint');
await myQueue.add('wall', { color: 'pink' }, { priority: 10 });
await myQueue.add('wall', { color: 'brown' }, { priority: 5 });
await myQueue.add('wall', { color: 'blue' }, { priority: 7 });
// The wall will be painted first brown, then blue and
// finally pink.
If several jobs are added with the same priority value, then the jobs within that priority will be processed in FIFO (First in first out) fashion.
Copyright (c) Taskforce.sh Inc.