Choosing Between Message Queues and Event StreamsĀ
Implementing an event-driven architecture (EDA) is a road riddled with challenges. Among them is choosing the right tooling for the job. Many event-driven tools seem quite similar, at least at first glance, and youād expect they could be used equally well for the same purposes. But thatās often not the case and choosing the solution best suited to your needs can be tricky. Take, for instance, message broker technologies. Choosing a message broker might seem straightforward at first. However, āmessage brokerā is an umbrella term often used to describe different types of components, such as event buses, pub/sub messaging services, message queueing systems and event streaming platforms. While thereās some overlap in terms of capabilities and use cases between all these types of components, there are also plenty of significant differences. Itās critical to understand these distinctions before embracing one message broker technology or the other (or a mixture of them). Iāll focus specifically on message queueing and event streaming, highlighting their differences, common denominators and suitability for various use cases. As a follow-up read, I recommend the āGuide to the Event-Driven, Event Streaming Stack,ā which talks about all the components of EDA and walks you through a reference use case and decision tree to help you understand where each component fits in.
Understanding Messages Queues and Event Streams
Before discussing message queues and event streams, letās first clarify what āmessageā and āeventā mean. A message is a generic term used to describe a packet of data sent from one component to another. There are different types of messages, including:- Command message. It carries instructions for the receiver to perform a specific action.
- Query message. A request made to obtain information from a component.
- Reply message. Sent by a server or recipient in reply to a request/query message.
- Transactional message. Used in systems where messages are part of a transaction and must be processed in a reliable, often atomic way.
{
"commandId": "cmd-987654321",
"commandType": "ProcessBankTransfer",
"data": {
"transactionId": "abc123",
"fromAccountId": "45678",
"toAccountId": "98765",
"amount": 100.00,
"currency": "USD"
}
}
{
"eventId": "evt-123456789",
"eventType": "BankTransfer",
"timestamp": "2023-12-13T09:45:30Z",
"eventData": {
"transactionId": "abc123",
"fromAccountId": "45678",
"toAccountId": "98765",
"amount": 100.00,
"currency": "USD"
}
}

Message queueing overview
- Event streaming involves a continuous flow of event messages. (You wouldnāt usually deal with such a high volume and velocity of data with message queues).
- The broker usually stores event messages in topics (or channels). Unlike point-to-point queues where a single receiver consumes each message, topics use the pub/sub model, allowing multiple consumers to read the same message.
- Messages can be stored in order for longer periods of time. (They are not discarded as soon as they are consumed).
- While the main purpose of message queues is to deliver messages from point A to point B reliably, event streaming follows a different paradigm. Event streaming does that too, but aside from distribution, it typically also transforms event data in real time before delivering it to its destination (so, the high-level flow is A > data transformation > B). Data transformation usually involves using stream processing technologies such as Kafka Streams or Apache Flink.

Event streaming overview
Message Queueing vs. Event Streaming Tech: Comparing Capabilities
There are numerous distinctions between technologies that allow you to implement event streaming and those that you can use for message queueing. To highlight them, I will compare Apache Kafka (event streaming platform) and RabbitMQ (message broker offering message queues). Iāve chosen Kafka and RabbitMQ specifically because they are popular, widely used solutions providing rich capabilities that have been extensively battle-tested in production environments. Theyāre considered by many to be the gold standard.| Attribute | Kafka (event streaming) | RabbitMQ (message queues) |
| Supported protocols | Custom binary protocol over TCP. | Several protocols supported: AMQP (0-9-1 and 1.0), STOMP, MQTT. Additionally, RabbitMQ can be extended to support Java Message Service (JMS) applications (via a plugin and a JMS client). |
| Message ordering | Guaranteed at partition level (a partition is a segment of a topic). | Guaranteed at queue level. |
| Delivery semantics | Supports at least once, at-most-once and even exactly-once semantics (the latter being crucial for industries like banking, where data integrity is critical). | Supports at least once and at-most-once semantics. No exactly-once delivery. |
| Message priority | No native support. | Supports priority levels per message, delivering higher-priority messages first. |
| Message replay | Allows replaying messages multiple times, even if already read by consumers. | No message replay capability. |
| Dead letter queues | Kafka supports the concept of dead letter queues, which is useful for error handling (see this article for details). | RabbitMQ supports dead-letter queues, allowing you to diagnose and resend messages that were not successfully processed by consumers. |
| Routing | Advanced content-based routing is possible via the Kafka Connect and Kafka Streams components. | Advanced, flexible routing capabilities via routing keys and exchange types. |
| Built-in stream processing | Yes (Kafka Streams). | No built-in capabilities. |
| Message consumption | Consumers use a pull model (long polling) to read messages. | Consumers can pull messages, or the broker can push them (the push model is the recommended option). |
| Broker andconsumer type | Dumb broker, smart consumer. | Smart broker, dumb consumer. |
| Data persistence | Offers long-term persistence, can retain data indefinitely. | Queues only retain messages until they are delivered and processed by consumers. |
| Scalability | Up to trillions of messages per day, thousands of topics split into tens of thousands of partitions and hundreds of brokers. | Scalable, but not designed for the same levels of scalability as Kafka. Better suited for small and medium-sized deployments and workloads. |
| Performance | Up to millions of messages and multiple gigabytes of data per second with consistently low latencies (in the single-digit milliseconds range). | Optimized to handle lower throughputs (thousands or tens of thousands of messages per second). Can offer very low latency (comparable to Kafka), but latency increases with high throughput workloads. |
Message Queueing and Event Streaming Use Cases
Message queueing and event streaming can both be used in scenarios requiring decoupled, asynchronous communication between different parts of a system. For instance, in microservices architectures, both can power low-latency messaging between various components. However, going beyond messaging, event streaming and message queueing have distinct strengths and are best suited to different use cases. Message queueing technologies are generally a good choice for:- Communication between components written in different languages and āspeakingā different protocols. Message queueing solutions like RabbitMQ and ActiveMQ make this possible by supporting multiple protocols and programming languages.
- Use cases that require complex message routing (for example, a stock trading platform that routes buy and sell orders to different processing queues based on the type of stock and order size).
- Distributing tasks among worker nodes, where each task is processed only once by a single consumer.
- Handling consumers that frequently disconnect. Message queueing systems are a good choice in these cases due to their message ordering, temporary persistence and message redelivery capabilities.
- Collecting, persisting and transmitting large volumes of event streams, such as clickstream data, stock market tickers and high-frequency readings from IoT devices and sensors.
- Continuously processing and analyzing data as it arrives to provide actionable insights and enable real-time decision-making (for instance, analyzing financial transactions as they happen to identify fraudulent ones and mitigate them as soon as possible).
- Event sourcing. A technology like Kafka is ideal in such scenarios because its immutable and append-only log structure ensures a reliable, ordered and replayable record of events. This enables the full historical sequence of state changes to be stored and queried.
- Log aggregation use cases. Event streaming solutions are a fitting choice because they generally offer good performance, strong durability guarantees and low latency. Additionally, event streaming technologies usually integrate with numerous other systems (or provide straightforward ways to do so), making it convenient to ingest log data from disparate components.