RabbitMQ & AMQP (50 Qs)•Part 2: Core Architecture & Implementation (Mid-Level)
What are Quorum Queues (Raft consensus) and why do they replace legacy Mirrored Queues?
senior LevelCode ExampleSystem DesignRabbitMQData Structures
In Simple Words:
- Legacy Mirrored Queues (Classic HA with Mnesia):
- Replicated messages across cluster nodes using a custom, non-standard synchronization protocol.
- Prone to silent message loss during network splits, slow sync times, and cluster deadlocks. (Deprecated in RabbitMQ 3.8 and removed in 4.0).
- Quorum Queues:
- Implemented using the Raft consensus algorithm.
- Provides strong consistency and fault tolerance: writes require confirmation from a majority ($N/2 + 1$) of nodes.
- Predictable recovery, faster failovers, and significantly higher throughput for persistent messages.
javascript
await channel.assertQueue('critical_payments', {
durable: true,
arguments: {
'x-queue-type': 'quorum',
'x-delivery-limit': 5 // Automatically dead-letters after 5 failed delivery attempts!
}
});