0
0
RabbitMQdevops~10 mins

Shovel and Federation for multi-DC in RabbitMQ - Step-by-Step Execution

Choose your learning style9 modes available
Process Flow - Shovel and Federation for multi-DC
Start: Message in DC1 Queue
Shovel or Federation picks message
Connect to DC2 Broker
Publish message to DC2 Queue
Message available in DC2
End
Messages flow from one data center's queue to another using Shovel or Federation, connecting brokers across data centers.
Execution Sample
RabbitMQ
rabbitmqctl set_parameter shovel myshovel '{"src-uri":"amqp://dc1","src-queue":"task_queue","dest-uri":"amqp://dc2","dest-queue":"task_queue"}'
This command sets up a Shovel to move messages from 'task_queue' in DC1 to 'task_queue' in DC2.
Process Table
StepActionSource Queue StateShovel/Federation StateDestination Queue StateResult
1Message arrives in DC1 'task_queue'1 messageIdle0 messagesMessage queued in DC1
2Shovel connects to DC1 and DC2 brokers1 messageConnected0 messagesShovel ready to transfer
3Shovel fetches message from DC1 queue0 messagesFetching message0 messagesMessage taken from DC1
4Shovel publishes message to DC2 queue0 messagesPublishing message1 messageMessage delivered to DC2
5Shovel confirms delivery and idles0 messagesIdle1 messageMessage ready for consumers in DC2
6No more messages, Shovel waits0 messagesIdle1 messageWaiting for new messages
💡 Shovel waits idle when no messages remain in source queue
Status Tracker
VariableStartAfter Step 1After Step 3After Step 4Final
DC1 Queue Messages01000
Shovel StateIdleIdleFetching messagePublishing messageIdle
DC2 Queue Messages00011
Key Moments - 3 Insights
Why does the DC1 queue message count drop to zero before the message appears in DC2?
Because the Shovel removes the message from DC1 queue first (Step 3) before publishing it to DC2 (Step 4), ensuring no duplicates.
What happens if the connection to DC2 broker fails during publishing?
The Shovel will retry publishing and keep the message until successful, preventing message loss (not shown in table but important).
How is Federation different from Shovel in this flow?
Federation links exchanges or queues to forward messages continuously, while Shovel moves messages one by one actively; both connect DCs but differ in setup and behavior.
Visual Quiz - 3 Questions
Test your understanding
Look at the execution table, at which step does the DC1 queue become empty?
AStep 4
BStep 2
CStep 3
DStep 5
💡 Hint
Check the 'Source Queue State' column in the execution table rows
According to the variable tracker, what is the Shovel state after Step 4?
APublishing message
BIdle
CFetching message
DDisconnected
💡 Hint
Look at the 'Shovel State' row and the 'After Step 4' column in variable_tracker
If a new message arrives in DC1 after Step 6, what will the Shovel state likely be?
AIdle
BFetching message
CDisconnected
DPublishing message
💡 Hint
Refer to the flow where Shovel fetches messages when available (see execution_table Step 3)
Concept Snapshot
Shovel and Federation connect RabbitMQ brokers across data centers.
Shovel actively moves messages from source queue to destination queue.
Federation links exchanges or queues to forward messages continuously.
Use Shovel for reliable, controlled message transfer.
Use Federation for continuous message sharing.
Both enable multi-DC message replication.
Full Transcript
This visual execution shows how RabbitMQ Shovel moves messages between two data centers (DC1 and DC2). First, a message arrives in DC1's queue. The Shovel connects to both DC1 and DC2 brokers, then fetches the message from DC1 queue, removing it there. Next, it publishes the message to DC2 queue. After confirming delivery, the Shovel idles waiting for new messages. Variables like queue message counts and Shovel state change step-by-step. Key points include that messages are removed from source before publishing to destination, and Shovel retries on failures. Federation differs by linking queues or exchanges for continuous forwarding. The quiz checks understanding of message flow and Shovel states. This helps beginners see how multi-DC message replication works in RabbitMQ.