When to use RabbitMQ shovels and when Federation plugin?
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.
RabbitMQ is an open-source message broker that efficiently supports complex routing scenarios and message queuing. A common challenge in distributed systems involves deciding the optimal method to share or synchronize messages across different brokers or networks. RabbitMQ provides two primary mechanisms for this purpose: Shovel and Federation. Understanding when to use each can optimize messaging architectures and ensure system scalability and reliability.
Understanding RabbitMQ Shovels
Shovels in RabbitMQ are components that actively move messages from a source queue to a destination queue, potentially across different brokers. Shovels work by connecting to the source and destination brokers simultaneously. They then transfer messages using standard AMQP protocols or custom configurations.
Use Cases for Shovels
- High Volume, Low Latency: Shovels are ideal for scenarios requiring high-throughput and low-latency direct message delivery to another broker. They can efficiently handle large volumes of messages without significant delays.
- Cross Data-Center Replication: In architectures demanding real-time data replication across different data centers, shovels can ensure data synchronization without administrative overhead at the network level.
- Conditional Replication: Shovels can be configured with advanced filtering properties to selectively replicate messages based on specific criteria or headers. This is beneficial in environments where not all messages in a queue need to be duplicated elsewhere.
- Temporary Data Migration: During system upgrades or migrations, shovels can temporarily move data to a new broker or cluster without impacting the existing messaging flow.
Understanding RabbitMQ Federation
Federation in RabbitMQ extends the idea of shovels with more emphasis on eventual consistency and linking queues over unreliable networks. It does not actively move messages but instead, it waits for messages to be consumed (pulled) by the destination.
Use Cases for Federation
- Loose Coupling: When different systems or services must be kept loosely coupled yet need access to the same set of messages, federation can synchronize queues over long distances without tight dependency on the broker's state.
- Incremental Scaling: Federation is ideal when the messaging system needs to scale incrementally. It allows separate brokers or clusters to join the network and start receiving messages with minimal configuration.
- Intermittent Connections: Federated queues are perfect for scenarios where network connections are unreliable or intermittent. The federation links are resilient to network failures and can buffer messages until the connection is restored.
- Geographically Distributed Systems: When systems are spread across multiple geographic locations, federation helps by connecting brokers in a way that each maintains its autonomy while ensuring messages are shared across locations.
Example Implementations
Shovel Configuration
To configure a Shovel in RabbitMQ:
- Enable the Shovel plugin:
- Define the Shovel via the management UI or a configuration file:
Federation Configuration
Setting up Federation involves:
- Enable the Federation plugin:
- Configure the upstream source:
- Define a federated queue:
Comparison Table
| Feature | Shovel | Federation |
| Connection Type | Active connection (Push mechanism) | Passive connection (Pull mechanism) |
| Use Case | High-throughput, low-latency tasks | Scalable, loosely-coupled systems |
| Network Reliability | Requires stable networks | Suitable for intermittent connections |
| Administrative Overhead | Requires continuous monitoring | Low maintenance once configured |
| Message Delivery | Immediate replication of messages | Asynchronous, eventual consistency |
| Configuration Complexity | Requires precise configuration | Easier to set up and manage |
Conclusion
The choice between Shovel and Federation in RabbitMQ should be guided by the specific requirements of your application. For critical, time-sensitive tasks where large volumes of data are involved, Shovels are generally more appropriate. Meanwhile, Federation suits scenarios where network stability is an issue or when incremental scalability and loose coupling are primary concerns. Both techniques offer robust solutions but excel under different conditions.
Related reading
- where can I find maven repository for kafka?
- Where does a BasicReject with requeue actually go?
- Where is Apache Kafka placed in the PACELC-Theorem
- where is rabbitmq config file?
- Where is the error log file destination for Zookeeper distributed with Kafka?
- Where kafka stores partitions for the topics?
- Where should you update Celery settings? On the remote worker or sender?
- Where to set maximum message size in Apache Kafka?

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
System Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.