Skip to main content

Message Queue vs Event Streaming vs Pub/Sub

The terms message queue, event streaming, and publish-subscribe are frequently used in discussions about distributed systems, yet they refer to distinct communication models with different goals, guarantees, and design trade-offs. Engineers often treat them as interchangeable, which leads to architectural confusion and poor technology choices.

A message queue is designed for reliable, point-to-point task processing. Event streaming is built around high-throughput, ordered, replayable logs. Publish-subscribe enables one-to-many broadcasting of events. Each model has its place, and modern systems frequently combine them. Understanding the differences is essential before diving into specific technologies like RabbitMQ, Apache Kafka, or Apache Pulsar.

What Is a Message Queue?​

A message queue is a communication channel where a producer sends a message to a queue, and a consumer retrieves and processes it. Crucially, each message is typically consumed by only one consumer (or one in a group of competing consumers). Once the consumer acknowledges successful processing, the message is removed from the queue.

The primary goal is reliable asynchronous task processing. The queue acts as a buffer that decouples the producer from the consumer and ensures that work is not lost, even if the consumer is temporarily unavailable.

Common use cases:

  • Background job execution (image processing, report generation)
  • Email or SMS delivery offloaded from a web request
  • Payment processing workflows
  • Order fulfillment steps
  • Distributing work across multiple worker instances

In a message queue, the focus is on getting a piece of work done exactly once and then moving on. Retention is short—messages exist only until they are consumed and acknowledged.

What Is Event Streaming?​

Event streaming is the practice of recording events in an append-only, immutable log. Producers write events to a stream, and those events are retained for a configurable (often long) period. Multiple independent consumers can read from any point in the stream, at their own pace, and can replay historical events.

The goal is to capture a continuous, ordered sequence of facts that can be used for a wide range of purposes, from real-time processing to retrospective analysis and state rebuilding.

Characteristics of event streaming:

  • Events are immutable and never deleted after consumption
  • Long-term retention (days, weeks, or indefinitely)
  • Multiple consumer groups read independently, each with its own position
  • High throughput and horizontal scalability
  • Ability to replay entire event histories

Common use cases:

  • Real-time analytics and dashboards
  • Audit logging and compliance
  • Data integration pipelines (CDC, ETL)
  • Event sourcing (storing state as a sequence of events)
  • Stream processing applications (filtering, aggregation, joining)

Event streaming is less about discrete task completion and more about making a continuous stream of data available to many consumers for diverse processing needs.

What Is Publish-Subscribe?​

Publish-subscribe (pub/sub) is a messaging pattern where a publisher sends a message to a topic, and all subscribers to that topic receive a copy of the message. It is a one-to-many broadcast mechanism. The publisher has no knowledge of who the subscribers are or how many exist.

The goal is to notify multiple interested parties about an event in a decoupled manner. Pub/sub is often the communication backbone for event-driven architectures where many services need to react to a single occurrence.

Common use cases:

  • Sending notifications (a new order triggers email, SMS, and dashboard updates)
  • Cache invalidation across multiple cache instances
  • Real-time monitoring and alerting
  • Propagating business events across bounded contexts
  • Fan-out scenarios where one message feeds many downstream processes

Pub/sub is primarily a communication pattern, not a product. Many messaging technologies implement pub/sub capabilities, often layered on top of queues or streams.

Conceptual Comparison​

DimensionMessage QueueEvent StreamingPublish-Subscribe
Primary purposeReliable task processingHigh-throughput, ordered, replayable event logOne-to-many event broadcasting
Communication modelPoint-to-point (or competing consumers)Log-based, multiple independent consumersOne publisher to many subscribers
Consumer modelOne consumer processes each message; removed after ackMultiple consumer groups read independently, each maintaining its own offsetAll active subscribers receive a copy of the message
Message retentionShort-term, until consumedLong-term, configurable retentionTypically short-term; driven by subscriber presence
Replay capabilityNo replay (message consumed once)Full replay from any offsetUsually not replayable; new subscribers get only new messages
OrderingOften best-effort within a queue; strict ordering limits parallelismStrong ordering within a partitionOrdering depends on implementation; not guaranteed across subscribers
ScalabilityModerate, through competing consumersMassive horizontal scalability via partitionsScale through topic partitioning and subscriber parallelism
ThroughputModerate to highVery high (millions of events/sec)High, but limited by subscriber processing
Typical workloadsTask distribution, background jobsReal-time pipelines, analytics, event sourcingNotifications, state propagation, fan-out
Example technologiesRabbitMQ, Amazon SQS, ActiveMQApache Kafka, Amazon Kinesis, Redis StreamsGoogle Cloud Pub/Sub, Azure Service Bus Topics, Redis Pub/Sub

Keep in mind that real-world products often blend these models, as we'll explore.

Common Misconceptions​

"Kafka is just a message queue."
Kafka is fundamentally an event streaming platform. While you can use it for queue-like workloads (via consumer groups and compacted topics), its architecture is built around the log abstraction. Treating it as a traditional queue without understanding its semantics (e.g., message retention, offset management) often leads to misuse.

"RabbitMQ cannot do pub/sub."
RabbitMQ has strong support for publish-subscribe via its exchange types (fanout, topic). However, it implements pub/sub over a queue-based model, meaning each subscriber typically has its own queue. This is a different internal mechanism from a log-based pub/sub system, but the pattern is the same.

"Pub/sub and event streaming are the same thing."
They solve different problems. Pub/sub is about distributing events to multiple live subscribers at the moment they occur. Event streaming is about recording events durably for future consumption, replay, and retrospective processing. A system can be both a streaming platform and a pub/sub system, but the concepts are distinct.

"Every messaging system behaves like a traditional queue."
Many systems provide queue-like semantics, but the underlying implementations differ dramatically. A Kafka consumer group behaves like competing consumers, but the underlying offset commit and rebalance mechanics are very different from a RabbitMQ queue with explicit acknowledgments.

"Event streaming replaces message queues."
They are complementary. Streaming excels at high-volume, ordered event flows, but a lightweight queue is often a better fit for simple background job processing where retention and replay are unnecessary overhead.

How Modern Messaging Systems Support Multiple Models​

Most production-grade messaging systems implement more than one model, and this flexibility is part of their value.

RabbitMQ​

  • Queue-based messaging with acknowledgments, dead-letter exchanges, and delayed messages.
  • Publish-subscribe through exchanges (fanout, direct, topic, headers) that route copies to bound queues.
  • Routing capabilities that allow selective distribution based on message content.

Apache Kafka​

  • Event streaming via partitioned, append-only logs with long retention.
  • Publish-subscribe via topic subscriptions; multiple consumer groups can independently read the same topic.
  • Queue-like behavior when a single consumer group processes a topic partition; each message is consumed by one member of the group.

Apache Pulsar​

  • Queuing through shared subscriptions, where messages are distributed across multiple consumers.
  • Publish-subscribe through exclusive and failover subscriptions, as well as topic broadcasting.
  • Event streaming with tiered storage, long retention, and replay.

Categorizing a product as "a message queue" or "an event streaming platform" is a simplification. It is more useful to understand which models a product supports and how those models are implemented, so you can map them to your architectural needs.

Choosing the Right Communication Model​

When to Choose a Message Queue​

  • The primary need is to distribute tasks among workers.
  • Each message should be processed exactly once and then removed.
  • Long retention and replay are not required.
  • You value simplicity and battle-tested reliability for discrete jobs.

When to Choose Event Streaming​

  • You need to persist and order millions of events per second.
  • Multiple consumers need to read events independently, often with different processing speeds.
  • Replay of historical events is required (auditing, reprocessing, state rebuild).
  • The system must support stream processing, analytics, or data integration.

When to Choose Publish-Subscribe​

  • A single event must be delivered to many interested services.
  • Subscribers change frequently, and the publisher should not be affected.
  • Real-time notifications or cache invalidation are the driving use case.
  • Loose coupling between publishers and subscribers is a primary architectural goal.

In practice, a single system often employs multiple models. For example, an e-commerce platform might use a message queue for background order processing, event streaming for real-time analytics on user behavior, and pub/sub for broadcasting order status changes to notification, shipping, and accounting services.

Relationship to Messaging Systems​

These conceptual models map to specific technologies in approximate ways:

  • RabbitMQ → Strong queue model, robust pub/sub via exchanges
  • Apache Kafka → Primary event streaming, with pub/sub and queue-like consumer groups
  • Apache Pulsar → Unified queuing, pub/sub, and streaming
  • Amazon SQS → Pure queue model (with FIFO options)
  • Google Cloud Pub/Sub → Primarily pub/sub with some streaming-like retention
  • Azure Service Bus → Queues and pub/sub topics with enterprise features

This mapping is a high-level guideline, not a rigid classification. Each product's implementation of a model has specific semantics and trade-offs explored in the Messaging Systems section.

Where This Fits in the Learning Path​

This article clarifies the conceptual differences between the three core messaging models. With this mental map, you can now delve deeper:

  • Messaging Foundations – Understand message lifecycle, delivery guarantees, ordering, and reliability, which apply across all three models.
  • Messaging Systems – Explore how Kafka, RabbitMQ, Pulsar, and cloud services implement these models.
  • Messaging Patterns – Learn patterns like Competing Consumers, Publish-Subscribe, and Event Sourcing, which build on these models.
  • Event-Driven Architecture – See how these models combine to form event-driven systems at scale.

Related articles:

Conclusion​

Message queues, event streaming, and publish-subscribe are not competing synonyms; they are three different architectural abstractions. A message queue reliably hands off discrete tasks to workers. Event streaming persists ordered event histories for independent, high-throughput consumption and replay. Publish-subscribe broadcasts events to many live subscribers for immediate reaction.

Understanding these distinctions—and how modern messaging systems blend them—gives you a powerful framework for evaluating technologies and designing communication flows. Products will come and go, but the clarity of these models will remain essential to building robust distributed systems.