New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More β†’

bullmq

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

bullmq

Queue for messages and jobs based on Redis


Version published
Weekly downloads
1M
increased by5.35%
Maintainers
0
Weekly downloads
 
Created
Issues
286

What is bullmq?

BullMQ is a powerful, fast, and feature-rich library for handling distributed job queues in Node.js. It is built on top of Redis and provides a robust set of features for managing background jobs, scheduling tasks, and handling concurrency.

What are bullmq's main functionalities?

Job Queue Management

BullMQ allows you to create and manage job queues. You can add jobs to a queue and process them using workers. This is useful for offloading tasks that can be processed asynchronously.

const { Queue, Worker } = require('bullmq');
const myQueue = new Queue('my-queue');

// Adding a job to the queue
myQueue.add('my-job', { foo: 'bar' });

// Processing jobs from the queue
const worker = new Worker('my-queue', async job => {
  console.log(job.name); // 'my-job'
  console.log(job.data); // { foo: 'bar' }
});

Job Scheduling

BullMQ supports job scheduling, allowing you to delay the execution of jobs. This is useful for tasks that need to be executed at a later time.

const { Queue } = require('bullmq');
const myQueue = new Queue('my-queue');

// Scheduling a job to run in 5 seconds
myQueue.add('my-delayed-job', { foo: 'bar' }, { delay: 5000 });

Concurrency Control

BullMQ allows you to control the concurrency of job processing. You can specify the number of jobs that can be processed simultaneously by a worker.

const { Worker } = require('bullmq');

// Creating a worker with concurrency of 5
const worker = new Worker('my-queue', async job => {
  console.log(job.name);
}, { concurrency: 5 });

Job Retries

BullMQ provides options for retrying failed jobs. You can specify the number of retry attempts and the backoff time between retries.

const { Queue } = require('bullmq');
const myQueue = new Queue('my-queue');

// Adding a job with retry options
myQueue.add('my-retry-job', { foo: 'bar' }, { attempts: 3, backoff: 5000 });

Other packages similar to bullmq

FAQs

Package last updated on 30 Jan 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts