liveBook · Manning

Routing key

As explained in Spring in Action, Sixth Edition

A routing key is a string carried with a RabbitMQ message that an exchange uses to determine message routing.

A routing key is a string carried with a RabbitMQ message. The message goes to an exchange, which uses the routing key, exchange type, and queue bindings to route it to one or more queues. Producers send messages to exchanges; consumers receive them from queues. section 9.2

Routing behavior depends on the exchange:

  • Default exchanges route messages to a queue whose name matches the routing key. section 9.2
  • Direct exchanges route messages when the routing key matches a binding key. section 9.2
  • Topic exchanges match routing keys against binding keys that may contain wildcards. section 9.2
  • Fanout exchanges deliver to all bound queues without considering routing keys. section 9.2
  • Headers exchanges route using message headers instead of routing keys. section 9.2

Configuring a taco-order route

Spring Boot can configure RabbitTemplate with an exchange and routing key: exchange `tacocloud.order` and routing key `kitchens.central`. Sending code can then use RabbitTemplate to publish the order through the configured messaging setup. section 9.2.2

Figure 9.2 Messages sent to a RabbitMQ exchange are routed to one or more queues, based on routing keys and bindings.

Use the routing diagram to follow a message from its exchange through bindings to one or more queues. section 9.2

How Spring in Action, Sixth Edition covers it

How deep it goes
Defines routing behavior across exchange types and applies it through RabbitTemplate, without detailing broker internals.
Examples
Uses the `kitchens.central` routing key with the `tacocloud.order` exchange in Spring RabbitMQ configuration.
What it assumes
Assumes basic messaging awareness while distinguishing exchanges, queues, bindings, and routing keys during the explanation.
What you can do after
Apply routing keys through RabbitTemplate send and convertAndSend methods.
How it connects
Connects exchanges, queues, bindings, binding keys, RabbitTemplate, message conversion, and message headers.

This explainer was generated by Manning's knowledge graph from the text of Spring in Action, Sixth Edition. The section links point to the parts of the book it draws on.