RabbitMQ: bind multiple routing keys to a single queue
Codemia Knowledge Hub ·
Yes, one queue can have many bindings. Bind it to the same exchange once per routing key, and the exchange delivers any message whose routing key matches one of those bindings. This is mainly useful with direct and topic exchanges.
Exchanges, queues and bindings
- Exchanges receive messages from producers and push them to queues according to routing rules.
- Queues store messages until a consumer handles them.
- Bindings are the rules an exchange uses to route messages to queues.
Exchange types
- Direct exchange: routes by the message's routing key.
- Topic exchange: routes on multiple criteria taken from the routing key.
- Fanout exchange: sends to every bound queue, ignoring the routing key.
- Headers exchange: routes on header attributes.
- Default (nameless) exchange: routes directly to the queue named in the routing key.
How multiple bindings route messages
Each binding key is a separate route by which the exchange can deliver to the queue. When a message arrives, the exchange checks which queues have a binding that matches its routing key and routes it there. A queue with several bindings can therefore collect messages from multiple producers or on varied criteria.
Example: orders and stock updates in one queue
A queue needs both "new orders" from customers and "stock updates" from inventory:
- Exchange: create a topic exchange,
topic_logs. - Queue: create a queue,
critical_updates. - Bindings: bind
critical_updateswith two routing keys:order.*stock.*
Messages published to topic_logs with routing key order.new or stock.update both land in critical_updates.
These use rabbitmqadmin, the CLI that ships with the management plugin; rabbitmqctl has no commands for declaring exchanges, queues or bindings. You can also declare bindings from client code.
Benefits
| Benefit | Description |
| Flexibility | Can receive different types of messages in one queue based on varied routing keys. |
| Simplified Architecture | Reduces the number of queues and exchanges needed, simplifying the architecture. |
| Enhanced Message Filtering | Provides a granular level of control over which messages are routed to particular queues. |
| Improved System Scalability | Helps in scaling the system by segregating critical routes efficiently without overloading a queue. |
Costs to watch
- Performance: more bindings make routing more complex, which can affect performance.
- Maintenance: many bindings become hard to manage, especially when routing requirements change often.
Related reading
- RabbitMQ - Multiple instances reading from the same Topic
- RabbitMQ - purge a queue from all of its unacked messages
- Rabbitmq - queues state shows as ''running'' , GUI shows status as IDLE
- RabbitMQ - Random queues with name amq.gen-* getting autogenerated
- RabbitMQ - Send a JSON message
- RabbitMQ - upgraded to a new version and got a lot of PRECONDITION_FAILED unknown delivery tag 1
- RabbitMQ - vhost '/' is down for user 'XYZ'. even after user has all access
- RabbitMQ - Wildcard in routing key vs binding key
System design interview problems on this topic
- Design a Distributed Messaging System: solution and walkthrough
- Design a Log Collection and Analysis System: solution and walkthrough
- Design an Ad Click Aggregation System: solution and walkthrough
- Design a Webhook Notification Service: solution and walkthrough

System Design Fundamentals
Build a strong foundation in designing scalable, reliable distributed systems.
View the courseSystem Design practice on Codemia
Work through 120+ system design problems with detailed solutions, from rate limiters to multi-region storage.