Skip to content

Message queues explained: how they work, RabbitMQ, Kafka, SQS and BullMQ, DLQs and the outbox

Why use a queue, the difference between a queue that deletes and a log that keeps, delivery guarantees, dead-letter queues, the outbox and how to choose between RabbitMQ, Kafka, SQS and BullMQ.

Ramon Gomes 18 min read Level: Intermediate

Also available in: Español, Français, Português

Picture the "Place order" button. When you click it, the system has to charge the card, issue the invoice, send the email, notify inventory and update the dashboard. If the API does all of that before answering, the person sits there watching the spinner. If the email service is down, the whole purchase fails because of an email.

A queue fixes this. The API records the order, puts the rest of the work in a queue and answers right away. Other processes, the consumers (or workers), pick up the tasks and handle each one in their own time. If one of them crashes, the task is still there, waiting.

This article explains how queues work, compares the most used tools (RabbitMQ, Kafka, SQS, BullMQ and Redis) plus the second-tier ones worth knowing, and shows the mistakes that come up most. I checked the facts against each tool's official documentation on November 21, 2026.

Restaurant kitchen during the rush, with paper order tickets hanging in a row on a metal rail above the counter and cooks preparing dishes in the background
The waiter doesn't wait for the dish to be ready before taking the next order. The ticket goes on the rail and the kitchen works at its own pace.

Why Use a Queue

The restaurant ticket is the best analogy I know. The waiter writes down the order, hangs it on the rail and goes back to the dining room. The kitchen pulls the tickets in order, as fast as it can. If a tour bus shows up, the rail fills up, but nobody gets sent away.

Animation comparing two ways to process a purchase: in the first, the API calls payment, invoice, email and inventory in sequence and the user waits for all of it; in the second, the API saves the order, publishes to the queue and answers in milliseconds, while the consumers process in parallel
Without a queue, the user waits for the sum of everything. With a queue, they only wait for the order to be saved.

In software, a queue brings four gains:

  • Fast response: the API only saves and publishes. The slow work happens later.
  • Decoupling: the publisher doesn't need to know who consumes, or whether they're up right now.
  • Absorbing spikes: on Black Friday, the queue grows and the consumers drain it. Without a queue, the spike takes down the target service.
  • Retrying: if processing fails, the message goes back to the queue and gets tried again.

The cost is real: one more piece to run, eventual consistency (the dashboard updates seconds later, not instantly) and a new kind of bug, the duplicate message. For a small API with fast operations, a queue can be overkill. The API concepts article helps decide what needs to be synchronous.

The Vocabulary in One Table

Term What it is
Producer Whoever publishes the message
Consumer (worker) Whoever reads and processes it
Broker The server that stores and delivers the messages
Ack The consumer's confirmation: "processed it, you can delete it"
Redelivery The message goes back to the queue because no ack came
DLQ (dead-letter queue) The queue that receives messages that failed too many times
Fan-out One message copied to several different consumers
Offset In a log, the position up to which the consumer has read

A Queue That Deletes or a Log That Keeps

This is the difference that confuses people most, and the one that weighs most in the choice.

Side by side animation: on the left, a classic queue where each message is delivered to one consumer and disappears after the confirmation; on the right, a log where messages stay stored in sequence and two consumer groups read at different positions, each with its own offset marker
In a queue, reading means consuming. In a log, reading just moves the marker.

Classic queue (RabbitMQ, SQS, BullMQ, the Redis list): the message is delivered to one consumer and, after the ack, deleted. It's the right model for tasks: "issue this invoice", "send this email". Each task should be done once, by someone.

Log (Kafka, Redis Streams, RabbitMQ streams): messages stay stored in sequence for a while (in Kafka, 7 days by default), and each consumer keeps its own offset, the position where it stopped. Reading doesn't delete. It's the right model for events: "order 42 was paid". Several systems can read the same event, and you can go back in time and reprocess.

One question settles most cases: will anyone need to read this message again later? If the answer is yes (auditing, a new system that needs the history, reprocessing after a bug), you want a log.

Delivery Guarantees

The Kafka documentation defines the three guarantees with a clarity that's hard to beat:

Guarantee Official definition In practice
At most once "Messages may be lost but are never redelivered" Fine for metrics or debug logs
At least once "Messages are never lost but may be redelivered" The default for almost everything
Exactly once "Each message is processed once and only once" It exists, but always with conditions
Consumer A charges R$ 120,00 for order #42 and crashes before the ack. The queue redelivers to B. Without a key there are two charges; idempotency recognizes key #42 and skips the second.
The consumer did the work and crashed before the ack. As far as the broker knows, the message wasn't processed. It comes back.

The scenario in the animation happens in production: the consumer processes, crashes before confirming, and the message is delivered again. AWS says it plainly about SQS: there's no "absolute guarantee" that a message won't be delivered more than once. RabbitMQ recommends making the consumer idempotent instead of trying to deduplicate everything. BullMQ warns that a job can run again if the worker crashes.

Idempotent means doing it twice gives the same result as doing it once. Charging a card isn't idempotent by nature; charging with a key the payment gateway recognizes as "already processed" is. This topic deserves its own article, and it will get one.

And "exactly once"? It always comes with an asterisk:

  • In Kafka, it holds within Kafka itself (read, transform and write to another topic in the same transaction). With an external database or API, it depends on that system cooperating.
  • In Google Pub/Sub, it's optional, only for pull subscriptions and in the same region.
  • In SQS FIFO, a repeated send within 5 minutes doesn't duplicate, but consumption can still repeat.

The Tools

RabbitMQ: The Router

RabbitMQ (version 4.4.1, from November 16, 2026, MPL 2.0 license) is the classic broker. What sets it apart is routing: the producer doesn't publish straight to a queue, it publishes to an exchange, which decides which queues the message goes to.

In RabbitMQ, direct delivers to the queue with the matching key; topic matches the key against order.*.paid; fanout copies the message to dashboard and audit.
The exchange is the mail carrier: it reads the address and decides which boxes the letter lands in.
  • Direct: delivers by the exact routing key.
  • Topic: delivers by pattern, like pedido.*.pago.
  • Fanout: copies to every bound queue, ignoring the key.

To avoid losing messages when a server goes down, the current standard is quorum queues, replicated with the Raft algorithm: the producer only gets the confirmation after a majority of replicas have written it. In 4.0, the old mirroring of classic queues was removed for good. In 4.4, quorum queues got native delayed messages, something that used to require a plugin.

Two details that catch people: without acks, delivery is "at most once"; and, since 4.0, a message that fails 20 times in a quorum queue is dropped if you haven't configured a dead-letter exchange.

When to use it: routing by event type, several consumers with different interests, a standard protocol (AMQP) across different languages.

Apache Kafka: The Distributed Log

Kafka (version 4.4.0, from October 22, 2026, Apache 2.0 license) isn't a queue in the classic sense. It's a partitioned log: each topic is split into partitions, each partition is an ordered sequence, and messages stay there until retention expires.

Animation of a Kafka topic with three partitions; messages with the same key always land in the same partition; a consumer group with three members reads one partition each, while a second group reads the same topic independently
Order only exists within a partition. And each partition has a single reader per group.

Three rules explain almost everything:

  1. Order is guaranteed within the partition, not across the topic. That's why you use a key (the order ID, for example): messages with the same key land in the same partition and arrive in order.
  2. In a consumer group, each partition has only one reader. Six partitions allow at most six consumers in parallel in that group. The seventh sits idle.
  3. Different groups read independently. Finance and the dashboard read the same topic, each with its own offset.

Two recent changes matter. Kafka 4.0 (March 2025) retired ZooKeeper: the cluster runs on KRaft only, and anyone on the old setup has to migrate before upgrading. And share groups (the "Queues for Kafka" project, KIP-932) became production ready in 4.2: several consumers can split the same partition, with per-message acknowledgment, closer to a queue. The project document itself warns that this doesn't turn Kafka into a queue, and that order can break on redeliveries.

What Kafka doesn't have natively, as far as the 4.4 documentation shows: delayed messages, and a DLQ in the classic consumer (it exists in Kafka Connect and in share groups).

When to use it: very high volume, events consumed by several systems, a need to reprocess history, data streaming.

Amazon SQS: The Serverless Queue

SQS is managed by AWS: there's no server to maintain. The consumer fetches messages, processes them and deletes them explicitly.

  • Standard: "at least once" delivery, best-effort ordering, nearly unlimited throughput.
  • FIFO: strict order per message group (MessageGroupId) and deduplication on send within 5 minutes. It has a ceiling: without high throughput mode, 300 transactions per second per action (3,000 messages with batches of 10).

The core concept is the visibility timeout: when a consumer takes a message, it becomes invisible for a while (30 seconds by default, up to 12 hours). If the consumer doesn't delete it before the deadline, it goes back to the queue. Too short a timeout causes duplicate processing; too long delays the next attempt.

SQS limit Value
Message size 1 MiB (it was 256 KiB until August 2025)
Retention 4 days by default, up to 14 days
Delivery delay up to 15 minutes
Standard price (US East, N. Virginia) US$ 0.40 per million requests, with 1 million free per month

Watch the bill: each 64 KB chunk counts as one request, so a 1 MiB message counts as 16. To send the same message to several queues, the partner is SNS: an SNS topic pushes a copy to each subscribed SQS queue.

When to use it: you're already on AWS, want zero operations, have variable throughput.

BullMQ: The Node Job Queue

BullMQ (version 6.7.8, MIT license, around 14 million weekly downloads on npm) is a library, not a server. It uses Redis (and, since version 6, from July 2026, PostgreSQL too) to store jobs, and ships with what an app usually needs:

ts
import { Queue, Worker } from 'bullmq';
import IORedis from 'ioredis';

const connection = new IORedis({ maxRetriesPerRequest: null });
const emails = new Queue('emails', { connection });

// Try 5 times, waiting longer between each attempt
await emails.add('boas-vindas', { usuarioId: 42 }, {
  attempts: 5,
  backoff: { type: 'exponential', delay: 1000 },
  delay: 60_000, // only after 1 minute
});

new Worker('emails', async (job) => {
  await enviarEmail(job.data.usuarioId);
}, { connection });

Priority, delayed jobs, retries with growing waits, rate limiting, cron scheduling and dependencies between jobs (flows) come out of the box. If you're upgrading to 6: ioredis is now installed separately, and the old repeat option was dropped in favor of job schedulers.

When to use it: a Node app that already has Redis and needs background tasks, like email, reports and image processing. It's the simplest choice on this list.

Redis: Three Ways, One That Loses Messages

Redis shows up in almost every conversation about queues, and it has three different features that people mix up:

Feature Stores the message? Guarantee Good for
List (LPUSH/BRPOP) Yes Lost if the consumer crashes after popping it Simple queue; use BLMOVE to make it reliable
Pub/Sub No At most once Real-time notices where losing one doesn't matter
Streams Yes At least once, with groups and XACK A real queue, with redelivery

The Redis documentation is blunt about Pub/Sub: if the subscriber can't handle the message, it's "lost forever". Using Pub/Sub as a task queue is one of the most common mistakes I see.

About the license: Redis 8 went back to offering an open source option (AGPLv3), after a period when it only had restrictive licenses. In the meantime Valkey was born, a Linux Foundation fork under the BSD license, backed by AWS and Google Cloud, which started from the Redis 7.2.4 code.

Second Tier: Worth Knowing

  • NATS with JetStream: a lightweight binary that does pub/sub, request and reply and, with JetStream, a persistent queue with redelivery. Good if you want few pieces to run.
  • Google Cloud Pub/Sub: Google's managed equivalent, with native fan-out, messages up to 10 MB and optional "exactly once".
  • Azure Service Bus: Microsoft's managed broker, strong on enterprise features: sessions for ordering, a DLQ on every queue, scheduled delivery and transactions.
  • Apache Pulsar: combines queue and log, with subscription types ranging from exclusive to key-shared, and native delayed delivery.
  • Redpanda: compatible with the Kafka API, written in C++, no external dependencies. Check the license before adopting it.
  • A queue in Postgres itself: SELECT ... FOR UPDATE SKIP LOCKED, the pgmq extension or the pg-boss library. If the project already has Postgres and volume is moderate, you skip a new piece, and the task goes into the same transaction as the order.

Side by Side Comparison

RabbitMQ Kafka SQS BullMQ Redis Streams
Model Queue with routing Partitioned log Managed queue Job queue Simple log
Reading deletes? Yes (queues) No Yes, on delete Yes No, until trimmed
Order Per queue Per partition FIFO per group Per queue, with priority Per stream
Native delay Yes (4.4) No Up to 15 min Yes No
DLQ Dead-letter exchange Only Connect and share groups Yes Failed jobs queue Manual
Operations You run it You run it (or managed) Zero Redis Redis

Poison Messages and the Dead-letter Queue

A message with invalid data always fails. With no limit, it goes back to the queue forever, burns processing and can block the ones behind it.

Animation of a broken message that fails, goes back to the queue, fails again with a growing wait between attempts and, on reaching the attempt limit, is diverted to the dead-letter queue, while the healthy messages keep flowing normally
Retries with growing waits, a limit and a place for the message that can't be fixed.

The recipe is the same in every tool: retry with growing waits (exponential backoff), limit the number of attempts and divert to a DLQ whatever goes over the limit. Then someone looks at the DLQ, fixes the cause and resends. The resilience patterns article explains retry and backoff in detail.

Two SQS gotchas: in a Standard queue, the DLQ retention clock starts at the original send, so the DLQ needs a longer retention than the source; and, in a FIFO queue, moving a message to the DLQ can break the order.

The Problem a Queue Doesn't Solve Alone: The Outbox

A classic bug: the code saves the order to the database and then publishes to the queue. If the process crashes between those two lines, the order exists and the event never goes out. If you flip the order, you can publish an event for an order that was never saved.

The outbox pattern, described by Chris Richardson, solves this: the message is written to a table in the database itself, in the same transaction that saves the order. A separate process reads that table and publishes to the broker. Since that process can publish the same message twice, the consumer still has to be idempotent. That's why a queue in Postgres (pg-boss, pgmq) is so appealing: the task is born inside the transaction.

Cartoon of a robot mail carrier delivering the same letter for the third time to a person at their front door who is already holding two identical letters and looks tired, while a dog watches
At least once means exactly that.

How to Choose

If you... Start with
Have a Node app with Redis and need background tasks BullMQ
Already use Postgres and volume is moderate pg-boss or pgmq
Are on AWS and don't want to maintain servers SQS (and SNS for fan-out)
Need to route messages by type to different consumers RabbitMQ
Need to store events, reprocess and handle very high volume Kafka
Want something light for lots of small services NATS

And the rule that applies to all of them: start with the simplest thing that works. Kafka for sending a welcome email is like renting a truck to deliver a letter.

Quick check

1. What's the core difference between a classic queue and a log like Kafka?
Show answer

Answer: In a queue, reading consumes the message; in a log, it stays stored and each reader keeps its own position

In a log, several groups read the same event and you can reprocess the history, because reading doesn't delete.

2. The consumer processed a payment and crashed before confirming. What happens in an "at least once" queue?
Show answer

Answer: The message is delivered again, and the payment can be processed twice if the consumer isn't idempotent

Without the ack, the broker assumes the work wasn't done. That's why the consumer has to handle repeats.

3. Which Redis feature loses the message if nobody is listening?
Show answer

Answer: Pub/Sub

Pub/Sub delivers at most once and stores nothing. For a queue, use Streams or a list with BLMOVE.

Frequently Asked Questions

Are queues and messaging the same thing?

Messaging is the broad concept: systems exchanging messages asynchronously. A queue is one form of it, for tasks that someone does once. Pub/sub and event logs are others.

Do I need Kafka?

If you're asking, probably not. Kafka shines with very high volume, many consumers of the same event and a need to reprocess history. For an app's background tasks, BullMQ, SQS or a queue in Postgres do the job with far less operations work.

Can Redis work as a queue in production?

Yes, with the right feature: Streams or lists with BLMOVE, and persistence configured. Pub/Sub, no. Libraries like BullMQ already do that work for you.

RabbitMQ or Kafka?

RabbitMQ when the message is a task and routing matters. Kafka when the message is an event that several systems consume and that you want to keep. Plenty of companies use both.

How do I test code that uses a queue?

Test the consumer as a pure function with the input message, and the full flow with the real broker in a container. The back-end testing guide shows how to set up integration tests with containers.

References

Official documentation checked on November 21, 2026:

Source: https://ramongomessilva.com.br/blog/message-queues-explained · Accessed on December 02, 2026

Share Share on LinkedIn Share on X
Cite this article

Ready-made reference, with today as the access date.

ABNT

Brazilian standard (NBR 6023). Use it in theses and academic papers submitted in Brazil.

GOMES, Ramon. Message queues explained: how they work, RabbitMQ, Kafka, SQS and BullMQ, DLQs and the outbox. Ramon Gomes, 26 nov. 2026. Disponível em: https://ramongomessilva.com.br/blog/message-queues-explained. Acesso em: 2 dez. 2026.

APA

American Psychological Association style. Common in scientific papers and journals, especially in the social, behavioral and health sciences.

Gomes, R. (2026, November 26). Message queues explained: how they work, RabbitMQ, Kafka, SQS and BullMQ, DLQs and the outbox. Ramon Gomes. https://ramongomessilva.com.br/blog/message-queues-explained

BibTeX

Format for LaTeX users (Overleaf, for example). Paste it into your .bib file or import it into Zotero or Mendeley.

@online{gomes2026messagequeuesexplained,
  author = {Gomes, Ramon},
  title = {{Message queues explained: how they work, RabbitMQ, Kafka, SQS and BullMQ, DLQs and the outbox}},
  organization = {Ramon Gomes},
  year = {2026},
  month = nov,
  date = {2026-11-26},
  url = {https://ramongomessilva.com.br/blog/message-queues-explained},
  urldate = {2026-12-02}
}
Found a mistake?

Wrong fact, broken link, outdated information: tell me and I will fix it.

10 to 2,000 characters. If you can, point to the right source.

Only so I can reply. It never shows on any page of the site.

Written by

Ramon Gomes

Software Engineer

Full stack software engineer. I like taking a messy problem, listening to the people who live with it and shipping something that holds up day to day. These days I split my time between my own products, applied AI and client work.

Available for projects

Need Something Like This Built?

I build websites, systems, apps and AI automations, from design to deploy. Tell me what you need or see what I offer.

Related Articles