AMQP · Study deck
AMQP Connection and Channel Contracts
An AMQP application does not open a brand-new network pipe for every message.
Broker Bex is your guide for this deck.

After studying this chapter
Learning objectives
You will be able to:
- Name the long link. Name each small channel. Name each broker object. Name each owner.
- Test one closed channel. Test one closed link. Test old broker state. Save each result.
- Check channel numbers. Check frame order. Check access bounds. Keep each flow apart.
- Plan safe retry. Plan safe cleanup. Plan a full restart. Record what state remains.
Major section
One Connection, Many Channels, a Stateful Broker
A typical AMQP 0-9-1 client process keeps one or a small number of long-lived TCP/TLS connections to the broker and multiplexes lightweight channels inside each one.
- The other half of the picture is that routing topology belongs to the broker, not to client memory.
- A channel is a lightweight AMQP 0-9-1 protocol context: publishes, subscriptions, acknowledgements, and topology commands happen on a channel, and the broker keeps channel-scoped state.
Major section
One Connection, Many Channels, a Stateful Broker (continued)
The broker-side objects explain why this works.
- Opening a fresh TCP connection per operation would waste handshakes, memory, and file descriptors; channels let one connection carry concurrent conversations without confusing them with AMQP 1.0 sessions.
- Durable exchanges and queues can survive a broker restart; an exclusive queue ends with its declaring connection; auto-delete queues and expiry policies can remove temporary resources.
- That scope map determines the smallest safe recovery action.
Major section
One Connection, Many Channels, a Stateful Broker (continued)
A reconnecting client should therefore redeclare or passively verify the topology it expects instead of assuming that every resource has the same lifetime.
- Worked example -- gateway fan-in: Suppose an IoT gateway process publishes telemetry, receives command replies, and runs a small health consumer.
- That repeats TCP setup, TLS negotiation, AMQP authentication, and broker resource allocation for work that may last only milliseconds.
- If the command consumer is redeclared or restarted, the telemetry channel does not need a new socket.
- The gateway can reconnect after a crash, declare the same durable topology, and resume publishing through a fresh channel.
Major section
Connection vs Channel, and Declaring Topology
Later, a test consumer starts with the same queue name but declares it as non-durable.
- A passive declare checks existence without creating, which is how a consumer can fail fast if the expected queue is missing.
- Threads B and C each consume on their own channel with their own prefetch.
- The practical rule is to make topology declarations repeatable, but not ambiguous.
Major section
Everything Travels as Channel-Tagged Frames
A quiet connection still exchanges heartbeat frames on channel 0 so both sides know the TCP session is alive.
- So publishing one message is really a method frame + content header frame + body frames on the same channel, in order.
- Channel 0 is reserved for connection-global negotiation (connection.start, connection.tune, heartbeats).
- Those heartbeats do not acknowledge messages and do not prove a consumer processed anything; they only prove the connection has not gone silent.
Deck summary
Key takeaways
A typical AMQP 0-9-1 client process keeps one or a small number of long-lived TCP/TLS connections to the broker and multiplexes lightweight channels inside each one.
- The broker-side objects explain why this works.
- A reconnecting client should therefore redeclare or passively verify the topology it expects instead of assuming that every resource has the same lifetime.
- Later, a test consumer starts with the same queue name but declares it as non-durable.
- A quiet connection still exchanges heartbeat frames on channel 0 so both sides know the TCP session is alive.
Retrieval practice
Recall check 1 of 6

Broker Bex says: answer from memory, then check your reasoning.
Q1A gateway has one shared link and separate telemetry and command work. Where should each owner and route live?
Show answer
Answer: B Channels separate task state while the broker owns routing objects.
Retrieval practice
Recall check 2 of 6

Broker Bex says: answer from memory, then check your reasoning.
Q2Two AMQP channels share one connection. How should a trace preserve their operations?
Show answer
Answer: B Channel tags separate streams; ordering is scoped to each channel.
Retrieval practice
Recall check 3 of 6

Broker Bex says: answer from memory, then check your reasoning.
Q3A producer disconnects after declaring a durable exchange, a durable queue, and an exclusive reply queue. Which statement matches the chapter's broker-resource lifetime contract?
Show answer
Answer: C The broker owns routing topology, but declarations control lifetime.
Retrieval practice
Recall check 4 of 6

Broker Bex says: answer from memory, then check your reasoning.
Q4A production consumer must fail fast when its required queue is absent, without creating it. Which AMQP 0-9-1 declaration mode checks that condition?
Show answer
Answer: C A passive queue declaration checks whether the named queue exists without creating it.
Retrieval practice
Recall check 5 of 6

Broker Bex says: answer from memory, then check your reasoning.
Q5A Python service uses one AMQP connection and shares a single channel across four worker threads that all publish concurrently. Publishes intermittently corrupt or error. What is the correct fix and why?
Show answer
Answer: D AMQP 0-9-1 multiplexes channel-tagged frames over one TCP connection; a message is an ordered frame sequence on a single channel, so channels must not be shared across threads.
Retrieval practice
Recall check 6 of 6

Broker Bex says: answer from memory, then check your reasoning.
Q6A worker loses one channel, then later its shared connection. What recovery plan fits both faults?
Show answer
Answer: D Recovery follows the failed scope and checks broker objects.
Print reference
Answers 1 of 2
Answer key.
- B · Channels separate task state while the broker owns routing objects.
- B · Channel tags separate streams; ordering is scoped to each channel.
- C · The broker owns routing topology, but declarations control lifetime.
- C · A passive queue declaration checks whether the named queue exists without creating it.
- D · AMQP 0-9-1 multiplexes channel-tagged frames over one TCP connection; a message is an ordered frame sequence on a single channel, so channels must not be shared across threads.
Print reference
Answers 2 of 2
Answer key.
- D · Recovery follows the failed scope and checks broker objects.