CodePark/ questions / RabbitMQ: exchanges, queues & routing
START PRACTICINGPRACTICE
Backend question · Message queues & streaming › RabbitMQ: exchanges, queues & routing

RabbitMQ has had streams since 3.9. How does a stream differ from a queue, and when would you pick one?

A queue deletes a message once a consumer acknowledges it, and each message goes to one consumer. A stream keeps messages: it is a replicated, append-only log, and reading does not remove anything.

How a stream works:

  • Each consumer chooses where to start: first, last, next, a specific offset or a timestamp. An offset is a position in the log.
  • Data is removed only by retention limits on size or age.

Pick a stream when:

  • Many consumers need the same large volume of messages, without one queue per consumer.
  • Consumers need to replay history.
  • You need very high throughput.

Pick a queue when you want to share work between consumers, with per-message acks, dead-lettering and requeueing.

Streams make RabbitMQ behave a little like Kafka. But if your whole design is built around partitioned logs and long retention, Kafka is usually the better fit.

  • A stream is a replicated, append-only log, and reading does not delete messages.
  • Consumers choose an offset to start from and can replay old messages.
  • A stream removes data only by retention limits on size or age.
  • Streams are good for large fan-out, replay and high throughput.
  • Queues are still the choice for work distribution with acks and dead-letter exchanges (DLX).