In RabbitMQ, what role does a binding key play when connecting a queue to a topic exchange?
Think about how messages are selected for delivery to queues.
The binding key acts like a filter pattern. It tells the exchange to send messages to the queue only if the message's routing key matches the binding key pattern.
Given a topic exchange and a queue bound with the binding key '#', which messages will the queue receive?
The '#' symbol in binding keys is a wildcard. What does it match?
The '#' wildcard matches zero or more words separated by dots, so it matches all routing keys, meaning the queue receives all messages sent to the exchange.
You want a queue to receive messages with routing keys that start with 'logs.' followed by any words. Which binding key should you use?
Remember '*' matches exactly one word, '#' matches zero or more words.
'logs.#' matches routing keys starting with 'logs.' and any number of words after. 'logs.*' matches only one word after 'logs.'.
A queue is bound to a topic exchange with binding key 'app.*.error'. Messages are published with routing key 'App.service.error' but the queue receives nothing. What is the likely cause?
Check if the routing key matches the binding key pattern exactly, including case.
Routing keys are case-sensitive. If the routing key case does not match the binding key pattern, messages won't be routed.
Arrange the commands in the correct order to declare a queue, declare a topic exchange, and bind the queue with a binding key 'user.*.update'.
Think about what must exist before you can bind.
You must first declare the exchange, then the queue, then bind the queue to the exchange with the binding key.