What is a message binding in RabbitMQ?
Answer
A binding is a relationship between an exchange and a queue — it defines the routing rule for how messages flow from the exchange to the queue. Create a binding with a binding key: channel.queueBind(queue: "order_processing", exchange: "orders", routingKey: "order.created"). For a direct exchange: the binding key must exactly match the message's routing key. For a topic exchange: the binding key supports wildcards (order.* matches order.created but not order.item.created; order.# matches both). For a fanout exchange: the binding key is ignored — all bound queues receive every message. One exchange can be bound to multiple queues, and one queue can be bound to multiple exchanges. The binding concept separates the concerns of routing logic (exchange) from storage (queue), enabling the same exchange to route to different queues based on binding keys.