IT Glossary
Message queues: how they work and when to use one
The component where one program leaves tasks for another: a single consumer picks each up at its own pace, and the customer no longer waits for processing.
- 6
- sections
- 6
- questions answered
A message queue is a software component where one application, the producer, leaves tasks or events and another application, the consumer, picks them up and processes them later, each message by a single consumer, so the producer never waits for the work to finish. At a well-run fast-food counter the cashier does not cook. They take the order, put it on the rail and move to the next customer, while the kitchen works at its own pace. A message queue does the same thing between programs. The application that receives a task — send the invoice, process the image, notify the courier — drops it into a queue and answers the customer immediately, while a separate program picks it up and executes it when capacity allows. If the kitchen gets busy, orders wait in order rather than being lost. The business benefit is twofold: the website stays fast even while heavy work is happening behind it, and spikes in load stop knocking the system over because they are levelled out over time. If a service goes down, its messages stay in the queue until it returns, provided the queue is durable and the consumer confirms each message only after processing it.
Why it matters for your business
Users no longer wait for processing
Slow operations such as generating PDFs, sending email or synchronising systems move to the background — the customer gets instant confirmation while the heavy work happens behind.
Load spikes are levelled out
An avalanche of orders no longer suffocates the system: tasks line up and are processed steadily at whatever rate the infrastructure can sustain.
Messages survive a service outage
If the invoicing service is down for an hour, its messages wait in the queue and are processed on recovery, with no manual reconciliation. The conditions: a durable queue, confirmation after processing, and a retention period longer than the outage.
How a message queue works
The flow has three parts: the producer puts the message in, the broker (the queue itself) holds it, the consumer picks it up. The consumer processes the message and only then sends an acknowledgement (ack); only after the acknowledgement is the message removed from the queue. If no acknowledgement arrives in time, the message becomes visible again and is retried. In Amazon SQS this interval is the visibility timeout: 30 seconds by default, 12 hours at most.
After a number of failed attempts the message moves to a dead-letter queue (in RabbitMQ, a dead letter exchange), where a person can inspect it. Delivery is usually at-least-once: the Amazon SQS documentation states explicitly that with standard queues the same message can arrive twice. That is why the consumer must be idempotent, meaning that processing the same message again must not cause a double effect; for example, it checks the invoice number before issuing the invoice again.
Messages do not stay in a queue forever. In Amazon SQS retention is 4 days by default and 14 days at most, and a message can be 1 MiB at most. So you put an identifier or a link in the queue, not the file itself.
Message queue vs publish/subscribe (RabbitMQ vs Kafka)
In a queue, each message is processed by a single consumer; several consumers can work on the same queue and share the tasks (Azure Service Bus queues work this way). In the publish/subscribe model the message goes to a topic and each subscriber gets its own copy: Service Bus topics and subscriptions, Amazon SNS and Google Cloud Pub/Sub. When several systems must learn about the same event, you put pub/sub in front and one queue per consumer behind it.
RabbitMQ was built as a broker with queues and routing. Kafka was built as a distributed log: consumers read by position (offset), and records stay for the retention period, so they can be read again. The line has moved: RabbitMQ has had streams (a log) since version 3.9 in 2021, and Apache Kafka 4.2, announced on 17 February 2026, made share groups ("Kafka Queues") production-ready, so several consumers read from the same partition and acknowledge each record separately.
The practical rule, without a verdict: for per-task work with retries, delays and dead-lettering, choose a queue (RabbitMQ, SQS, Service Bus); for a high-volume event stream that several systems read and may replay, choose a log (Kafka, Event Hubs). If one system only needs to tell another that something happened, a webhook is the direct alternative, with no broker.
Want an estimate for your project?
Message us on WhatsApp. We reply the same working day, and the first 30-minute call is free.
Managed services and framework queues
At Amazon Web Services: Amazon SQS (queue), Amazon SNS (publish/subscribe), Amazon MQ (managed RabbitMQ or ActiveMQ) and Amazon MSK (managed Kafka). At Azure: Service Bus (queues and topics) and Event Hubs, which accepts Kafka clients. At Google Cloud: Cloud Tasks (task queue) and Pub/Sub (publish/subscribe).
In an ordinary web application the framework often has its own queue. Laravel queues run on the database, Redis, Amazon SQS or Beanstalkd, so you do not need a separate broker until volume asks for one.
When a message queue is worth it in a business application
It is worth it when slow work starts after a click (PDF, email, image processing); when you call external systems you do not control (sending an invoice to a tax authority's invoicing API, a courier API, a payment webhook) and a temporary outage must not block the order; or when traffic peaks appear (a campaign, Black Friday).
It is not needed when you have a few jobs a day at fixed hours: a cron job is enough. A request that must answer instantly, such as a stock check, stays synchronous. The real cost of a queue: one more component to monitor (queue length, dead-letter count) and results that appear after a few seconds, not instantly.
Frequently asked questions
Which message queues exist?
The open-source ones are RabbitMQ (queues with routing and dead-lettering) and Apache Kafka (an event log, with queues through share groups since version 4.2). Managed cloud options are Amazon SQS, Amazon MQ, Azure Service Bus and Google Cloud Tasks, chosen when you do not want to run the broker yourself.
What happens if a message fails to process?
Well-built systems retry automatically a few times, then move the message to a dead letter queue where a person can inspect it. That way you find out about problems without losing any data in the process.
Does a message queue slow the application down?
For the user it does the opposite: the response comes back immediately while the work happens asynchronously. The real trade-off is delay — the result appears within a few seconds rather than instantly, which for invoices, emails and reports is perfectly acceptable.
What is the difference between RabbitMQ and Kafka?
RabbitMQ routes each message into queues and deletes it after acknowledgement. Kafka keeps records in a log for the retention period, and consumers read by offset and can replay. With Kafka 4.2 (2026) and RabbitMQ streams (2021), each covers part of the other's model; choose by the work pattern.
What is the difference between a message queue and publish/subscribe?
In a queue, each message is processed by one consumer. In publish/subscribe, each subscriber gets its own copy (Service Bus topics, Amazon SNS, Google Cloud Pub/Sub). If several systems need the same event, put pub/sub in front and one queue per consumer behind it.
Can a message be processed twice?
Yes. Most queues guarantee at-least-once delivery (Amazon SQS states it explicitly for standard queues), so the consumer must be idempotent: a second run must not issue two invoices or send two emails. Check a unique identifier before acting.
Let’s talk about your project
Book a free 30-minute call or send us an email. We reply the same working day.
office@northdan.com · +40 750 252 851