BullMQ is a fast, reliable and highly customizable priority job queue for Node.js, based on the Redis database. Here are some common use cases of BullMQ:
const Queue = require('bull'); const myQueue = new Queue('myQueue'); myQueue.add({ email: 'example@example.com', subject: 'Welcome', message: 'Thank you for joining us!' });
myQueue.add({ email: 'example@example.com', subject: 'Subscription ending soon', message: 'Your subscription will end in 3 days.' }, { delay: 3 * 24 * 60 * 60 * 1000 // 3 days in milliseconds });
// High priority job myQueue.add({ email: 'example@example.com', subject: 'High Priority', message: 'This is a high priority job' }, { priority: 1 }); // Low priority job myQueue.add({ email: 'example@example.com', subject: 'Low Priority', message: 'This is a low priority job' }, { priority: 2 });
const rateLimitedQueue = new Queue('emailNotifications', { limiter: { max: 100, duration: 60000 // 100 jobs per minute } });
myQueue.add({ data: 'Repeat this job every day' }, { repeat: { cron: '* * * * *' } }); // Cron syntax for every minute
Remember that usage patterns can vary widely depending on the specific needs of your application. These are just some of the highlights of what BullMQ has to offer.
Dragonfly is fully compatible with the Redis ecosystem and requires no code changes to implement.