concept route key in category rabbitmq

This is an excerpt from Manning's book RabbitMQ in Depth.
When publishing a message to an exchange, applications use a routing-key attribute. This may be a queue name or it may be a string that semantically describes the message. When a message is evaluated by an exchange to determine the appropriate queues it should be routed to, the message’s routing key is evaluated against the binding key (figure 1.10). In other words, the binding key is the glue that binds a queue to an exchange, and the routing key is the criteria that’s evaluated against it.
Figure 1.10. A queue is bound to an exchange, providing the information the exchange needs to route a message to it.
![]()
In the most simple of scenarios, the routing key may be the queue name, though this varies with each exchange type. In RabbitMQ, each exchange type is likely to treat routing keys in a different way, with some exchanges invoking simple equality checks and others using more complex pattern extractions from the routing key. There’s even an exchange type that ignores the routing key outright in favor of other information in the message properties.
By default, the routing key is the value that’s hashed for distributing the messages. For an image, one possible routing key value is a hash of the image itself, similar to the hash that’s generated in the “6.2.2 Hashing Consumer” notebook. If you intend to distribute messages via hashes of the routing key values, nothing special is required when declaring the exchange. This is demonstrated in the “6.7 A Consistent-Hashing Exchange that Routes on a Routing Key” notebook.
7 Publishes the message with the MD5 hash as the routing key As you can see, the distribution is close but not exact. This is because the decision of where to place the queue is determined by the value used in routing, and it can’t truly load-balance messages in a round-robin way without very specific routing key values being crafted to ensure this behavior. If you’re looking to load-balance your messages among multiple queues but don’t want to use the consistent hashing approach, take a look at John Brisbin’s random exchange (https://github.com/jbrisbin/random-exchange). Instead of looking at the routing key to distribute the message among the queues, it uses random number generation. Given RabbitMQ’s plugin flexibility, it wouldn’t be surprising if a true round-robin exchange were to surface in the future. If this is something that interests you, perhaps it’s something you’ll be able to write.