AMQP · Study deck

AMQP Core Architecture: Exchange Types

AMQP is easiest to understand as a sorting office for messages.

Broker Bex is your guide for this deck.

archcorecomponents
Broker Bex, the module guide, in a scene from this chapter.
iotclass.org

After studying this chapter

Learning objectives

You will be able to:

  • Explain: Producers publish once (saving CPU and bandwidth), the broker handles routing (its core job), and each consumer receives only relevant messages.
  • Explain: Channel multiplexing benefit:: Each of the 1,200 robots uses a single TCP connection with 4 channels (one per sensor type).
  • Explain: The broker's pattern matching adds < 0.1 ms latency per message -- negligible for all three consumers' requirements.
  • Explain: The broker routing eliminates 67% of unnecessary deliveries compared to fanout (which would send to all 3 queues).
iotclass.org

Major section

Exchange Types

Different exchange types provide flexible routing patterns for various messaging scenarios.

  • Direct exchanges route messages based on exact routing key matches.
  • This reading connects deterministic routing with mandatory returns or alternate-exchange handling.
  • Each bound queue receives its own copy, allowing independent consumers to progress at different rates.
  • Routing key is dot-separated (e.g., "sensor.temperature.zone1").
Direct exchange routing sends a message only to queues whose binding key exactly matches the routing key, with an explicit policy for zero matches
Direct exchange routing sends a message only to queues whose binding key exactly matches the routing key, with an explicit policy for zero matches
iotclass.org

Major section

Exchange Types (continued)

That broadcast behavior supports notifications and audit copies, while also making subscriber count part of capacity planning.

  • Direct: Exact routing key match.
  • Best for multi-attribute rules; supports x-match: all or x-match: any.
  • AMQP exchange types at a glance: direct = exact match, fanout = broadcast, topic = wildcard patterns, headers = attribute matching.
iotclass.org

Major section

Real-World Case Study: Industrial IoT with AMQP Exchange Routing

Three backend systems consume this data differently.

  • Producers must publish each message 3 times to different exchanges.
  • Network load: 4,800 x 3 = 14,400 publishes/second.
  • Network load: 4,800 publishes/second (each message published once).
  • Broker routes to 1-3 queues per message based on bindings.
iotclass.org

Major section

Real-World Case Study: Industrial IoT with AMQP Exchange Routing (continued)

Each consumer processes 4,800 msg/s but discards 50-75% of them.

  • Producers publish once (saving CPU and bandwidth), the broker handles routing (its core job), and each consumer receives only relevant messages.
  • The broker's pattern matching adds < 0.1 ms latency per message -- negligible for all three consumers' requirements.
  • Channel multiplexing benefit:: Each of the 1,200 robots uses a single TCP connection with 4 channels (one per sensor type).
iotclass.org

Major section

Worked Example: Industrial IoT Message Routing with Topic Exchange

Result:: This single PUBLISH reaches 2 queues (Maintenance + Dashboard).

  • The broker routing eliminates 67% of unnecessary deliveries compared to fanout (which would send to all 3 queues).
  • 50 machines × 120 messages/hour = 6,000 publishes/hour.
  • With fanout exchange: 6,000 publishes × 3 queues = 18,000 deliveries (112% overhead).
iotclass.org

Deck summary

Key takeaways

Different exchange types provide flexible routing patterns for various messaging scenarios.

  • That broadcast behavior supports notifications and audit copies, while also making subscriber count part of capacity planning.
  • Three backend systems consume this data differently.
  • Each consumer processes 4,800 msg/s but discards 50-75% of them.
  • Result:: This single PUBLISH reaches 2 queues (Maintenance + Dashboard).
iotclass.org

Retrieval practice

Recall check 1 of 5

Broker Bex says: answer from memory, then check your reasoning.

Q1A routing key sensor.temperature.zone1 is published to a topic exchange. Which binding pattern will NOT match this routing key?

Asensor.#
Bsensor.*.zone1
Csensor.temp.#
D#
Show answer

Answer: C Topic exchange wildcards: * matches exactly one dot-separated word, and # matches zero or more.

Q2Place each app protocols concept where it lives so you can follow one AMQP message from sender through routing and storage to its receiver.

ABroker
BGateway
CLoad Balancer
DProxy Server
Show answer

Answer: A These boundaries keep publish message, route and hold, receive delivery distinct so you can follow one AMQP message from sender through routing and storage to its receiver.

iotclass.org

Retrieval practice

Recall check 2 of 5

Broker Bex says: answer from memory, then check your reasoning.

Q3Complete the AMQP exchange declaration and queue binding:

Achannel.exchange_declare(exchange='sensors', exchange_type='topic')
Bchannel.exchange_create(name='sensors', type='topic')
Cchannel.declare_exchange('sensors', 'topic')
Dchannel.exchange('sensors', exchange_type='topic')
Show answer

Answer: A In AMQP, exchanges are declared with exchange_declare() specifying the type (direct, fanout, topic, headers).

iotclass.org

Retrieval practice

Recall check 3 of 5

Broker Bex says: answer from memory, then check your reasoning.

Q4An industrial monitoring system has 200 machines publishing diagnostic data with routing keys like machine.line1.id042.vibration and machine.line2.id103.temperature. The maintenance team wants to subscribe to ALL vibration readings from ALL machines on ALL production lines using a single queue binding. Which exchange type and binding pattern is correct?

ADirect exchange with binding key machine.vibration
BFanout exchange (broadcasts all messages to the maintenance queue)
CTopic exchange with binding pattern machine.*.*.vibration
DHeaders exchange with header attribute sensor_type: vibration
Show answer

Answer: C

iotclass.org

Retrieval practice

Recall check 4 of 5

Broker Bex says: answer from memory, then check your reasoning.

Q5A smart building system publishes sensor messages with routing keys like sensor.temperature.floor3, sensor.humidity.floor1, and sensor.pressure.floor2. You need a single queue that receives ALL temperature readings from ALL floors, but nothing else. Which exchange type and binding pattern should you use?

AFanout exchange with no binding key
BDirect exchange with binding key sensor.temperature
CTopic exchange with binding pattern sensor.temperature.*
DHeaders exchange with x-match: any
Show answer

Answer: C

iotclass.org

Retrieval practice

Recall check 5 of 5

Broker Bex says: answer from memory, then check your reasoning.

Q6An IoT gateway uses AMQP channel multiplexing to handle data from 50 sensors simultaneously over a single TCP connection. One channel encounters an error due to a malformed message. What happens to the other 49 channels?

AThey continue operating normally because channel errors are isolated
BAll channels are closed because they share the same TCP connection
CThe broker closes the connection and all channels must reconnect
DThe other channels pause until the errored channel is manually reset
Show answer

Answer: A AMQP channel multiplexing provides isolation between channels on the same TCP connection.

iotclass.org

Print reference

Answers

Answer key.

  1. C · Topic exchange wildcards: * matches exactly one dot-separated word, and # matches zero or more.
  2. A · These boundaries keep publish message, route and hold, receive delivery distinct so you can follow one AMQP message from sender through routing and storage to its receiver.
  3. A · In AMQP, exchanges are declared with exchange_declare() specifying the type (direct, fanout, topic, headers).
  4. C
  5. C
  6. A · AMQP channel multiplexing provides isolation between channels on the same TCP connection.
iotclass.org