Exchanges and routing
On This Lesson 4 topics
This lesson is planned. The outline below lists the topics it will cover. The full lesson has not been published yet.
In this lesson
pick the right exchange type.
Planned topics
- Direct: routes on an exact routing key match.
- Topic: routes by patterns:
*matches one word,#matches zero or more. Exampleorder.*.created. - Fanout: copies to every bound queue; ignores the key.
- Headers exchanges also exist but are rare.
- Unroutable messages are dropped unless configured otherwise (mandatory flag or alternate exchange).
- Declare exchanges, queues, and bindings in code with Spring AMQP beans.
Draft outline details
Demonstration
@Bean TopicExchange notifications() { return new TopicExchange("notifications"); }
@Bean Queue emailQueue() { return QueueBuilder.durable("email").build(); }
@Bean Binding b(Queue emailQueue, TopicExchange notifications) {
return BindingBuilder.bind(emailQueue).to(notifications).with("order.#");
}Check your understanding
Which exchange type ignores the routing key?
Show answer
Fanout.
Practice
Apply this lesson with the module's lab, exercises and quiz.
Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.