Quick Start

This is a basic guide to get your first queue working.

Install

Install using npm:

$ npm install bullmq

Install using yarn:

$ yarn add bullmq
circle-info

BullMQ is written in TypeScript, and although it can be used in vanilla JavaScript, all examples in this guide will be written in TypeScript.

Import into your project and add some jobs:

import { Queue } from 'bullmq';

const myQueue = new Queue('foo');

async function addJobs() {
  await myQueue.add('myJobName', { foo: 'bar' });
  await myQueue.add('myJobName', { qux: 'baz' });
}

await addJobs();
triangle-exclamation

Jobs are added to the queue and can be processed at any time, with at least one Node.js process running a worker:

circle-info

You can have as many worker processes as you want, BullMQ will distribute the jobs across your workers in a round robin fashion.

You can listen to completed (or failed) jobs by attaching listeners to the workers:

circle-info

There are many other events available, check the Guidearrow-up-right or the API referencearrow-up-right for more information.

Sometimes you need to listen to all the workers events in a given place, for this you need to use a special class QueueEventsarrow-up-right:

You may also access the timestamp of the event, which looks like "1580456039332-0".

triangle-exclamation

Last updated

Was this helpful?