A log you can replay, or a queue that hands out each task once? How to choose.
A message queue hands each message to one consumer and then usually deletes it. An event stream is a log that keeps every event for a while, so many readers can read it, and read it again.
Both move messages from producers to consumers, so they look alike. The big difference is what happens after a message is read.
In a queue (RabbitMQ, SQS) several workers compete for messages. Each message goes to one worker. After the worker acknowledges it, the queue deletes it. The queue is a waiting list, not a history. (See Message Queues and RabbitMQ and SQS.)
In a stream (Kafka, Kinesis) events are appended to a log and kept for a retention period, such as days, or until a size limit. Reading does not delete anything. Each consumer group remembers its own offset (its position), so groups read independently and can move the offset back to replay. (See Kafka Deep Dive.)
1. Does each message need to be handled by one worker (a task), or seen by many systems (a fact that happened)?
2. Might I need to read old messages again? If yes, you want a log.
| Question | Message queue | Event stream |
|---|---|---|
| After a message is read | Removed from the queue | Stays in the log |
| Several independent readers | Needs extra setup (fan-out to more queues) | Built in: one consumer group each |
| Replay | Not possible | Yes, within retention |
| Ordering | Best effort, or per group in FIFO queues | Strict inside one partition |
| Scaling consumers | Add workers on the same queue | Up to the number of partitions per group |
| Failed message handling | Retry, delay and dead-letter per message | You manage offsets and build retry topics yourself |
| Who tracks progress | The broker | The consumer (an offset) |
| Best for | Tasks | Facts and history |
Simplified teaching model with fixed events. In a real stream, a new consumer group chooses where to start (the beginning or only new events), and events are deleted when the retention time or size limit is reached.
| Term | Meaning in easy words |
|---|---|
| Queue | A line of messages where each one is handled by one consumer and then removed |
| Stream / log | An ordered, append-only record of events that is kept for a while |
| Offset | A position in the log. A consumer group remembers its own |
| Consumer group | A set of consumers that share the reading of a stream. Each group sees every event |
| Competing consumers | Several workers reading one queue, each taking different messages |
| Retention | How long (or how much) the log keeps events before deleting the oldest |
| Replay | Reading old events again by moving the offset back |
| Partition | One ordered slice of a stream. Order is kept inside a partition |
| Acknowledgement | A consumer's note that a message is done, so a queue can delete it |
| Fan-out | Delivering one event to many separate consumers |
| Log compaction | Keeping only the latest event per key in a stream, instead of all of them |
| Choice | We gain | We lose |
|---|---|---|
| Queue | Simplicity and per-message tools | History, replay and easy fan-out |
| Stream | Replay, many readers, throughput | Simplicity and per-message control |
| Long retention | More room to replay and recover | More storage cost |
| More partitions | More parallel consumers | More overhead, and order only per partition |
| Hybrid | History plus easy task handling | Two systems to run |