Skip to content
Tutorials Center
My learning

Topics

Lesson 13 of 37 ยท Queues and Exchanges

Queue Types: Classic, Quorum and Streams

Compare RabbitMQ classic queues, quorum queues and streams: how each stores data, replication and Raft majorities, and which type to choose.

Not every queue has to behave the same way. RabbitMQ offers several queue types that store and replicate messages differently. You choose one with the x-queue-type argument when you declare the queue, and you cannot change it afterwards. Picking the right type early avoids painful migrations.

Declarations with pika are read-only examples. Runnable blocks are Python stand-ins that model the ideas (majority voting, non-destructive log reads); they do not implement Raft or the real stream protocol.

The three types

Queue types at a glance

Classic The original queue. Fast, single node, not replicated.
Quorum Replicated with Raft. The safe choice for important data.
Stream Append-only log. Many readers, replay from any offset.

Transient or exclusive queues must be classic.

1 / 2
Python
# real pika code, read-only
channel.queue_declare("orders",  durable=True, arguments={"x-queue-type": "quorum"})
channel.queue_declare("metrics", durable=True, arguments={"x-queue-type": "stream"})
channel.queue_declare("scratch")                                   # classic by default

A virtual host can also have a default queue type, so a plain queue_declare produces a quorum queue without the argument. Check what your broker uses before relying on the default.

Classic queues

Classic queues are the original design. A classic queue lives on one node. They are very fast for short queues and support the widest set of features: transient and exclusive queues, per-message priorities, and so on. Their weakness is availability: if the node hosting the queue is down, the queue is unavailable. Older versions could mirror classic queues across nodes; mirroring was removed in RabbitMQ 4.0, and replicated queues are now quorum queues or streams.

Use classic queues for temporary, private or non-critical queues, such as reply queues and per-consumer subscriptions.

Quorum queues

A quorum queue is a durable, replicated FIFO queue built on the Raft consensus algorithm. Every message is written to a majority of the queue's replicas before the publisher is confirmed. One replica is the leader; the others are followers. If the leader's node fails, the followers elect a new leader from the nodes that hold up-to-date data.

Key points:

  • Use an odd number of replicas (3 is typical, 5 for the most critical queues).
  • A queue stays available while a majority of replicas is up: 2 of 3, 3 of 5.
  • They are always durable and persist messages to disk, so the data is safe by design.
  • They have poison message handling: a delivery limit (x-delivery-limit) caps how often a message may be redelivered before it is dropped or dead-lettered, which prevents infinite redelivery loops.
  • They do not support exclusive queues or transient (non-durable) messages, and priority support is limited.
  • They use more disk and some extra latency than a classic queue, the price of safety.

Majority arithmetic is easy to get wrong, so try it:

Python Quorum arithmetic (stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Notice that 4 replicas tolerate only one failure, the same as 3, which is why odd counts are recommended.

A write needs a majority

The stand-in below mimics a publisher confirm: the leader appends the message, followers acknowledge, and the confirm is sent only when a majority has stored it. It is a teaching sketch, not Raft.

Python Confirm after majority (stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

(A real Raft leader would also stop accepting writes without a majority and followers would catch up later; this sketch only shows the confirm rule.)

Streams

A stream is an append-only log, like the commit logs used by Kafka, built into RabbitMQ. Differences from a queue:

  • Reading is non-destructive. A consumer reading a message does not remove it; messages stay until a retention policy (size or age) deletes the oldest segments.
  • Any number of consumers can read the same data, each starting at its own offset: first, last, next, a numeric offset or a timestamp.
  • They are replicated, and designed for very high throughput, large fan-out and replay.

Streams are declared like queues with x-queue-type: stream and retention arguments (x-max-length-bytes, x-max-age). They can be used with the normal AMQP 0-9-1 client (consumers must set a prefetch and acknowledge, and choose an offset with the x-stream-offset consume argument), or with a dedicated stream protocol on port 5552 for the highest performance.

Python Queue vs stream reading (stand-in)

Press Run (or Ctrl + Enter) to see the result here.

Program input ยท what you'd type while the program runs

Type the answers before you press Run, one per line. Each time the program reads a line (with input()), it gets the next line from this box.

Which type should I use?

A simple decision guide

Important work Orders, payments, jobs that must not be lost? Quorum.
Temporary or private Reply queues, per-client subscriptions? Classic.
Replay and fan-out Many readers, history, huge volume? Stream.

When unsure, start with a quorum queue.

1 / 2

Also remember that the type is fixed at declaration. To switch, create a new queue and move traffic (a shovel or publishing through a new binding can help; see operations later in the course).

Check your understanding

Quick check ยท 4 questions

of 4 answered You scored / 4 ยท perfect!

  1. 1. How is the queue type chosen?

    The type is a declaration argument and cannot be changed afterwards.
  2. 2. A quorum queue has 5 replicas. How many nodes can fail while it stays available?

    A majority is 3 of 5, so up to 2 nodes may be lost.
  3. 3. What is different about reading a stream?

    Stream messages stay until retention removes them, so many consumers can read and replay independently.
  4. 4. Which queue type should hold critical orders that must survive node failure?

    Quorum queues replicate with Raft and persist messages, so they tolerate node failures.

Summary

  • Classic queues: single node, fast, flexible, not replicated (mirroring is gone in RabbitMQ 4).
  • Quorum queues: Raft-replicated, durable, majority-based, poison message handling; the default choice for important data.
  • Streams: replicated append-only logs with non-destructive reads, offsets and retention.
  • Use odd replica counts; the type cannot be changed after declaration.

Next: Queue Arguments: TTL, Length and Dead Letters