RabbitMQ · core
RabbitMQ exchanges, bindings and routing keys
In RabbitMQ a producer sends to an exchange, not to a queue. Bindings route messages to queues, and the exchange type decides how.
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceThe notes
What you must know
- Producers publish to an exchange with a routing key. Bindings connect the exchange to queues with a key or a pattern. Consumers read from queues.
- Topic exchange: words separated by dots. * matches exactly one word and # matches zero or more words.
- Example: a message with key order.cancelled.mumbai matches bindings order.# and .cancelled. but not order.* (two words only).
- Direct exchange: the routing key must equal the binding key. Fanout: ignores the key and copies to every bound queue. Headers exchange: matches on message headers.
- The default exchange routes to the queue whose name equals the routing key.
- A message that matches no binding is dropped silently, unless the publisher sets the mandatory flag or the exchange has an alternate exchange.
- One queue with several consumers means competing consumers: each message goes to one of them. One queue per service, each bound to the exchange, means every service gets its own copy.
- Current RabbitMQ also speaks AMQP 1.0 next to AMQP 0-9-1; the routing model is the same.
The red pen
Common traps: mistake → fix
Mistake: RabbitMQ sends to queues directly
Fix: producers use exchanges.
Mistake: Fanout looks at routing keys
Fix: it ignores them.
Mistake: Unroutable messages come back as errors
Fix: they vanish unless you use mandatory or an alternate exchange.
Easy to hard
Questions interviewers ask, easy to hard
- Explain exchanges, bindings and routing keys.
- Which queues get a message with key order.cancelled.mumbai, given these topic bindings?
- What is the difference between direct, topic and fanout?
- What happens to a message nobody is bound for?
Practise
Practise with these questions
Explain it out loud
Explain it out loud to an AI interviewer that follows up, and see where your answer is thin.
Practise by voiceYour first interview is free
Sign up and start with a 15-minute interview with the full report, and an English conversation. No card needed.