Skip to content
LATEST

🚀 Welcome to Upgradix by Shrash Studio – Your destination for free technology learning and career growth.

Upgradix
Upgradix Code. Learn. Ship.

Quorum Queues & RabbitMQ Streams for High Availability

A Quorum Queue replicates messages across multiple RabbitMQ nodes using Raft consensus so a server crash never loses data. A RabbitMQ Stream is an append-only log that lets multiple .NET services read and replay the same events at their own pace.

Quorum Queues & RabbitMQ Streams for High Availability

Quick Answer: A Quorum Queue replicates messages across multiple RabbitMQ nodes using Raft consensus so a server crash never loses data. A RabbitMQ Stream is an append-only log that lets multiple .NET services read and replay the same events at their own pace.

Imagine Meena runs a UPI payment app in Hyderabad. At 7:00 PM, Arjun sends ₹2,500 with transaction ID TXN-8891.

With a classic RabbitMQ queue, that payment message sits on a single broker node. If that server crashes before the settlement worker reads it, Arjun's payment event is gone.

How do we keep critical payment queues alive during server crashes, and also let analytics services replay past events?

1. Why Classic Queues Break Under Failure

The problem without quorum queues

Classic queues were built for single-node speed, not modern cloud clusters. Even when you mark a classic queue as durable, it lives on one machine.

Example 1: A classic queue on a single RabbitMQ node

This simple setup works on a laptop, but risks data loss in production.

// Default queue type is classic (no Raft replication)
await channel.QueueDeclareAsync(
    queue: "upi.payments.classic",
    durable: true,
    exclusive: false,
    autoDelete: false);

What happens when Node 1 crashes

Node 1 offline -> Queue upi.payments.classic is UNAVAILABLE!
TXN-8891 stuck on dead disk -> Settlement Service fails.

This setup works until a cloud server restarts. However, it breaks when real hardware fails.

  1. If Node 1 dies, the classic queue stops accepting and delivering messages.
  2. Poison messages can loop forever because classic queues lack built-in delivery limits.
  3. Once a consumer reads a message, it is deleted, so another service cannot replay it later.

Now think about a festival sale with 20,000 UPI payments per minute. We need automatic failover across nodes and a way to replay event history.

The solution: Quorum Queues and Streams

Quorum Queue = a replicated RabbitMQ queue backed by the Raft consensus protocol for high availability.

Raft Consensus = a voting rule where a majority of nodes (like 2 out of 3) must save a message before confirming it.

RabbitMQ Stream = a persistent, append-only log where messages stay after reading so consumers can replay them from any offset.

Live Flow: 3-Node Raft Quorum Replication & Automatic Failover

Watch Arjun's payment replicate across the cluster and survive a sudden Node 1 crash.

Step 1: Payment API writes TXN-8891 to Raft Leader (Node 1)
Arjun's UPI Payment API
Publishes TXN-8891 (₹2,500)
Write to Quorum Queue

RabbitMQ 3-Node Cluster · Queue: upi.payments.quorum

Node 1
Raft Leader · TXN-8891
Node 2
Raft Follower · Synced
Node 3
Raft Follower · Synced
Raft Majority Sync (2 of 3 Nodes)
Safe Delivery (Zero Data Loss)
Settlement Service (.NET)
Settles TXN-8891 without interruption
Producer Healthy Raft Node Crashed Node Active Step / New Leader

When Node 1 goes offline, Node 2 and Node 3 still form a 2-of-3 majority. Node 2 becomes the new Leader automatically, so Arjun's payment is never lost.

2. Configuring Quorum Queues & Streams in C# (.NET)

Delivery Limit = the maximum number of times RabbitMQ redelivers a failing message before sending it to a Dead-Letter Queue.

To create a Quorum Queue in C#, pass x-queue-type: "quorum" and set x-delivery-limit in the queue arguments.

Example 2: Declaring a Quorum Queue with a delivery limit in C#

Quorum queues must always be durable and non-exclusive.

var quorumArgs = new Dictionary<string, object?>
{
    ["x-queue-type"] = "quorum",
    ["x-delivery-limit"] = 3,              // Stop poison loops after 3 tries
    ["x-dead-letter-exchange"] = "upi.dlx"
};

await channel.QueueDeclareAsync(
    queue: "upi.payments.quorum",
    durable: true,
    exclusive: false,
    autoDelete: false,
    arguments: quorumArgs);

Now suppose Meena's Fraud Analytics service wants to replay the last 24 hours of UPI events. A Quorum Queue deletes messages after acknowledgment, so we use a RabbitMQ Stream instead.

Example 3: Declaring a RabbitMQ Stream and replaying from the start

Pass x-stream-offset when consuming to read from the beginning of the log.

var streamArgs = new Dictionary<string, object?>
{
    ["x-queue-type"] = "stream",
    ["x-max-age"] = "7D"                   // Keep event log for 7 days
};

await channel.QueueDeclareAsync("upi.events.stream", durable: true, exclusive: false, autoDelete: false, arguments: streamArgs);

// Replay from the very first stored event
await channel.BasicQosAsync(0, 100, false);
await channel.BasicConsumeAsync(
    queue: "upi.events.stream",
    autoAck: false,
    consumer: consumer,
    arguments: new Dictionary<string, object?> { ["x-stream-offset"] = "first" });

Expected output

[QuorumQueue]  TXN-8891 replicated to 3/3 nodes -> Settled
[StreamReplay] FraudService replayed TXN-8891 from offset 0

Quorum Queues protect your transactional work. Streams give your analytics and audit services a Kafka-like replayable log inside RabbitMQ.

3. Classic Queue vs. Quorum Queue vs. Stream

Choosing the right RabbitMQ queue type
Feature Classic Queue Quorum Queue RabbitMQ Stream
Replication Single node only Raft majority (High Availability) Raft-replicated append-only log
After consumer reads Deleted Deleted Kept until max age or size
Poison message limit None built-in Built-in (x-delivery-limit) Not applicable (non-destructive)
Best use case Temporary, non-critical jobs Payments, orders, critical tasks Event replay, audit logs, high fan-out

Design tip: Always run an odd number of RabbitMQ nodes (3 or 5) for Quorum Queues. A 3-node cluster tolerates 1 node crash, while a 5-node cluster tolerates 2 crashes.

4. Common Mistakes to Avoid

1. Deploying Quorum Queues on a 2-node cluster

Raft needs a strict majority to operate. In a 2-node cluster, if 1 node crashes, only 1 node remains, which is not a majority, so the queue freezes.

Better approach: Always deploy at least 3 RabbitMQ nodes in production.

2. Skipping x-delivery-limit on Quorum Queues

If a bad message crashes your .NET worker repeatedly, RabbitMQ will redeliver it forever and burn CPU.

Better approach: Always set x-delivery-limit (for example, 3 or 5) and attach a Dead-Letter Exchange.

5. Interview Questions & Practice

Question 1: When would you pick a RabbitMQ Stream over a Quorum Queue?

What the interviewer expects: Understanding of destructive consumption vs. replayable logs.

Strong answer: "I use a Quorum Queue for task processing like Arjun's UPI payment settlement, where each message should be processed once and removed. I use a RabbitMQ Stream when multiple services need to read the same high-volume event history or replay past events from an offset, like fraud analytics."

Practice: Railway ticket audit log

A railway booking system needs to process ticket payments safely AND let a new reporting service replay the last 30 days of bookings. Which two RabbitMQ queue types should you declare, and what key arguments do they need?

Expected result: A Quorum Queue (x-queue-type: quorum, x-delivery-limit: 3) for payments, and a Stream (x-queue-type: stream, x-max-age: 30D) for replayable booking logs.

6. Next Steps

  • Previous Article: Consumer Idempotency & Deduplication in .NET
  • Next Article: Hosting Background Consumers with BackgroundService in .NET

Discussion & Comments

1
Guest mode · Login / Register
Post directly as a guest or log in first.
K
Kiran kumar Guest
Nov 23, 2026

<p>Super article sir</p>

M Madhusudhan M Nov 23, 2026

Agree, explaination is very clear.

This article is protected. Printing and saving as PDF are disabled.