Skip to content
Ameen Abozaid
Planned lessonMID-027-L02

Exchanges and routing

  • Lesson 2 of 6
  • Mid-level
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. Example order.*.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

java
@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.

Lab and exercises Quiz

Marking a lesson complete is optional and you can undo it any time. Your progress stays in this browser.

Continue to next lesson

Type to search levels, phases, modules and lessons.