Hardware FixRecommendedDevice not working? Your driver may be the problemCheck updates for common hardware issues.Fix DriversHalloween DealsAmazon USHalloween week deals: useful picks before month-endAmazon US: current deals, useful picks and tech finds.Check DealsWindows FixRecommendedWindows errors stealing your time? Find the fix fastScan stability, cleanup and performance issues.Fix Now×
FREEDOM251

Freedom251 › Blog › BullMQ

How to Broadcast BullMQ Job Events to Multiple Listeners

By Freedom251 Team · · 3 min read

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Use BullMQ’s QueueEvents when one or more services need to observe job lifecycle events across every worker on a queue. Workers divide the work; they do not each receive a copy of every job. QueueEvents provides queue-wide event observation using Redis Streams, without adding a separate message broker for that purpose.

What “fan-out” means in BullMQ

BullMQ has two different patterns that can sound like fan-out. Workers consume jobs from a shared queue, so multiple workers distribute processing rather than each getting its own copy. Separately, a QueueEvents listener can observe lifecycle events generated by jobs handled across those workers.

As an Amazon Associate I earn from qualifying purchases.

Ordinary Queue and Worker event listeners are local to their process. A process that needs queue-wide visibility should use QueueEvents. If several independent services need to observe those events, each service can create its own QueueEvents instance and register the event types it needs. BullMQ’s Events guide describes the event scope and implementation.

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Set up a queue-wide event listener

Construct a QueueEvents instance with the queue name and Redis connection used by your application, then register handlers for the events that matter to the consumer. This TypeScript example illustrates the documented API; adapt the connection configuration to your application.

import { QueueEvents } from 'bullmq';

const queueEvents = new QueueEvents('orders', { connection });

queueEvents.on('completed', ({ jobId, returnvalue }) => {
  notifyConsumers({ type: 'completed', jobId, returnvalue });
});

queueEvents.on('failed', ({ jobId, failedReason }) => {
  notifyConsumers({ type: 'failed', jobId, failedReason });
});

await queueEvents.waitUntilReady();

// On application shutdown:
await queueEvents.close();
  1. Create the listener for the queue name with the appropriate Redis connection.
  2. Register handlers for the lifecycle events the service needs, such as completed, failed, or progress.
  3. Wait for readiness before relying on it, and close the instance during shutdown to release its Redis connection.
  4. Handle errors from workers and listeners. BullMQ warns that an unhandled worker error can stop processing.

A single instance can dispatch events to several callbacks within its process. Separate services that need independent observation should each instantiate their own listener.

Read event payloads without assuming they contain a Job

QueueEvents payloads are compact event data, not hydrated Job objects. Depending on the event, the payload commonly contains jobId and fields such as returnvalue, failedReason, or progress data. If a consumer genuinely needs the full job, retrieve it by ID; BullMQ’s quick start documents Job.fromId as an option. BullMQ Quick Start

Understand the delivery and retention limits

BullMQ documents QueueEvents as implemented with Redis Streams. Its Events guide says this provides delivery guarantees across disconnections that standard pub/sub does not provide. That does not make the event stream an unlimited archive: the stream is auto-trimmed to approximately 10,000 events by default. Configure streams.events.maxLen to change the maximum, and size retention against expected event volume and the downtime a listener may experience. BullMQ Events guide

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

These are queue lifecycle events, not a substitute for a separately designed durable business-event system. If downstream consumers must preserve every business fact independently of stream trimming or application downtime, define that requirement and its persistence and recovery behavior explicitly.

Use a different design when every consumer needs the job

If the requirement is for multiple consumers to process a separate copy of every job, QueueEvents is not job duplication: it observes lifecycle changes. BullMQ workers distribute jobs among themselves, and BullMQ recommends multiple workers for concurrency and availability. Design explicit job fan-out for independent processing rather than treating event observation as a copy of the work. BullMQ Workers guide BullMQ Queues guide

Redis is still part of the architecture

Using QueueEvents avoids adding a separate broker for queue-wide lifecycle observation, but BullMQ still requires Redis: jobs are stored in Redis, and the official quick start requires a running Redis service. BullMQ Quick Start

Publish custom events when lifecycle events are not enough

For event names beyond job lifecycle changes, BullMQ documents QueueEventsProducer for publishing custom events that QueueEvents consumers can subscribe to. This keeps the same event-observation approach while allowing application-specific event types. BullMQ Events guide

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.
Independent reader supportYour contribution helps us test, update, and keep practical guides available for everyone.Support on Ko-Fi

Choose the listener by scope

Approach What it observes Payload Disconnection and retention
Worker-local event listener Events in that worker’s process Worker event callbacks; not a queue-wide observer Local callback; does not provide the QueueEvents Redis Stream behavior
QueueEvents Lifecycle events across workers on the queue Compact event fields, commonly including jobId, not a full Job Redis Streams; auto-trimmed to approximately 10,000 events by default, configurable with streams.events.maxLen

The documentation pages cited here describe BullMQ APIs but do not specify a particular package version. Check the documentation matching your installed BullMQ version before relying on version-specific behavior.

Product prices and availability are accurate as of the date/time indicated and are subject to change. Any price and availability information displayed on Amazon at the time of purchase will apply.

BullMQjob queuesNode.jsQueueEventsRedis

Leave a Reply

Your email address will not be published. Required fields are marked *

Special offer. See more information about Outbyte and uninstall instructions. Please review EULA and Privacy policy.

Recommended PC Tool
Recommended PC Tool
Crashes, No Sound, or Screen Glitches?Free driver scan
PC Slower Than It Used to Be?Free scan - under a minute

Two free Windows tools

One Free Minute Could Fix That PC

Before you go - each of these free tools takes about a minute and tackles what quietly slows a Windows PC down.

Special offer. View Outbyte info, uninstall instructions, EULA, and Privacy Policy.