AMQP · Study deck
AMQP Core: Consumers and Topology Contracts
AMQP adds a smart sorting desk between senders and receivers.
Broker Bex is your guide for this deck.

After studying this chapter
Learning objectives
You will be able to:
- Explain: Direct is easiest to audit, fanout is easiest to reason about for broadcast, topic is the usual IoT default when keys carry hierarchy, and headers only pays off when routing depends on several independent attributes.
- Explain: If you only need the intuition: the exchange is a sorting rule, the binding key is the label on a mailbox slot, and the routing key is the address written on the envelope.
- Explain: One queue bound with plant1.# receives a site-wide copy, another bound with.line3. Receives the line-3 copy, and a third bound with #.vibration receives nothing.
Major section
Worked Example: Designing Multi-Tier Alert Routing with AMQP Topic Exchange
Scenario:: Manufacturing facility needs to route machine alerts to appropriate teams based on severity and location.
- The system has 100 machines across 4 production lines, and 3 alert levels (info, warning, critical).
- Server-side filtering reduces network traffic by 66% vs broadcast-and-filter approach.
- Adding new subscribers requires only 1 binding, not 100 per-machine configurations.
Major section
Worked Example: Designing Multi-Tier Alert Routing with AMQP Topic Exchange (continued)
Pattern-based routing scales to 1,000 machines with no binding changes (wildcards handle new machines automatically).
- Lesson Learned:: AMQP topic exchanges provide sophisticated routing that would require complex application-layer filtering with MQTT.
- The broker's pattern matching offloads work from consumers and reduces network bandwidth, making it ideal for enterprise IoT with multiple subscriber tiers needing selective message delivery.
- Wildcards reduce binding complexity from 6×100 machine-specific bindings to 6 pattern bindings.
Major section
AMQP Routing Topology Contracts
AMQP topology makes that a broker decision: exchanges inspect the routing key, bindings state who qualifies, and queues hold each matched copy.
- A successful publish does not prove that every required consumer received a copy.
- A protocol means an agreed set of message and behavior rules.
- A broker means the service that receives and routes messages.
Major section
AMQP Routing Topology Contracts (continued)
AMQP means Advanced Message Queuing Protocol, which defines roles and behavior for brokers, producers, queues, and consumers.
- The exchange holds no messages of its own; it evaluates every binding and enqueues one copy in each distinct destination queue reached by at least one match.
- That makes troubleshooting concrete.
- Numbers make the difference visible.
Major section
AMQP Routing Topology Contracts (continued)
The producer did not know those queue names and did not send three messages; the exchange evaluated three bindings and made two copies.
- MQTT also decouples publishers from subscribers through broker-side subscription matching; what it does not expose is AMQP 0-9-1's explicit exchange-binding-queue topology.
- Worked example: a temperature device publishes once to exchange iot.events with routing key plant1.line3.temperature.
- Queue topology, not worker count alone, controls the semantics.
Major section
AMQP Routing Topology Contracts (continued)
One queue bound with plant1.# receives a site-wide copy, another bound with.line3. Receives the line-3 copy, and a third bound with #.vibration receives nothing.
- If operations later adds a billing queue bound with plant1.line3.#, the producer still publishes the same packet, but the topology now creates a third copy.
- When a queue is empty, inspect the exchange name, routing key, and binding keys before blaming the producer.
- A perfectly published message can still be unrouted if no binding matches, or copied to several distinct queues if several routes match.
- Choosing one is choosing a matching rule, not a feature set.
Major section
AMQP Routing Topology Contracts (continued)
If you only need the intuition: the exchange is a sorting rule, the binding key is the label on a mailbox slot, and the routing key is the address written on the envelope.
- The four standard exchange types differ only in how they compare a routing key to a binding key.
- The comparison connects topology choice to test cases for positive matches, negative matches, and operational handling of unroutable messages.
- Direct is easiest to audit, fanout is easiest to reason about for broadcast, topic is the usual IoT default when keys carry hierarchy, and headers only pays off when routing depends on several independent attributes.
Major section
AMQP Routing Topology Contracts (continued)
Five independent analytics services that must each receive every event require five distinct queues with matching bindings.
- Every queue is automatically bound to it with a binding key equal to the queue's own name, so publishing to "" with routing key orders lands straight in the queue named orders.
- Exchange matching selects a set of distinct destination queues, which determines how many independently buffered service copies exist; consumers attached to one queue determine that service's in-flight processing capacity.
- If each service runs three worker instances, those three workers consume from that service's one queue.
Major section
AMQP Routing Topology Contracts (continued)
RabbitMQ normally dispatches across active consumers in round-robin order, but prefetch, consumer availability, priorities or single-active-consumer settings, and redelivery can change the observed distribution.
- If workers from all five services consume from one shared queue, only one service instance receives each delivery attempt; the other services do not receive independent copies.
- If all fifteen workers instead have separate queues with identical matching bindings, one publication produces fifteen queue copies -- three copies inside each service rather than one.
- In RabbitMQ, basic.qos(prefetch_count=10, global=false) applies the limit separately to each newly registered consumer.
Deck summary
Key takeaways
Scenario:: Manufacturing facility needs to route machine alerts to appropriate teams based on severity and location.
- Pattern-based routing scales to 1,000 machines with no binding changes (wildcards handle new machines automatically).
- AMQP topology makes that a broker decision: exchanges inspect the routing key, bindings state who qualifies, and queues hold each matched copy.
- AMQP means Advanced Message Queuing Protocol, which defines roles and behavior for brokers, producers, queues, and consumers.
- The producer did not know those queue names and did not send three messages; the exchange evaluated three bindings and made two copies.
Retrieval practice
Recall check 1 of 5

Broker Bex says: answer from memory, then check your reasoning.
Q1Complete the AMQP topic exchange setup with pika:
Show answer
Answer: A Pika uses BlockingConnection with ConnectionParameters for synchronous AMQP connections.
Q2Place each app protocols concept where it lives so you can separate connection scope from routing work and durable delivery state.
Show answer
Answer: A These boundaries keep scope connection, route message, hold delivery distinct so you can separate connection scope from routing work and durable delivery state.
Retrieval practice
Recall check 2 of 5

Broker Bex says: answer from memory, then check your reasoning.
Q3Per this chapter's Routing Path Contract section, when a downstream queue turns up unexpectedly empty, what should you check before assuming the producer is broken?
Show answer
Answer: A The chapter's troubleshooting rule: an empty queue is a topology question first.
Retrieval practice
Recall check 3 of 5

Broker Bex says: answer from memory, then check your reasoning.
Q4You need every one of five analytics services to process every telemetry message, and within each service you want to add workers to go faster. Which AMQP topology is correct?
Show answer
Answer: A Independent service queues control which services receive buffered copies; competing consumers on one service queue control that service's in-flight processing capacity.
Retrieval practice
Recall check 4 of 5

Broker Bex says: answer from memory, then check your reasoning.
Q5A smart factory uses an AMQP topic exchange for sensor data. Temperature sensors publish to sensor.temperature.line1 and vibration sensors publish to sensor.vibration.line2. The data lake queue is bound with pattern sensor.# and the temperature dashboard queue is bound with sensor.temperature.*. A message published with routing key sensor.temperature.line1 will be delivered to which queues?
Show answer
Answer: D
Retrieval practice
Recall check 5 of 5

Broker Bex says: answer from memory, then check your reasoning.
Q6An e-commerce platform processes 100,000 orders per second. Each order must be handled exactly once and distributed across 10 worker consumers. Which AMQP consumer pattern should be used?
Show answer
Answer: B Competing consumers is the correct pattern when each message must be processed exactly once with load distribution.
Print reference
Answers 1 of 2
Answer key.
- A · Pika uses BlockingConnection with ConnectionParameters for synchronous AMQP connections.
- A · These boundaries keep scope connection, route message, hold delivery distinct so you can separate connection scope from routing work and durable delivery state.
- A · The chapter's troubleshooting rule: an empty queue is a topology question first.
- A · Independent service queues control which services receive buffered copies; competing consumers on one service queue control that service's in-flight processing capacity.
- D
Print reference
Answers 2 of 2
Answer key.
- B · Competing consumers is the correct pattern when each message must be processed exactly once with load distribution.