# AMQP 0-9-1 Protocol Specification - Key Excerpts for Message Queue Consumers

**Authority Tier:** Tier 1 (Standards)
**Source:** https://www.rabbitmq.com/amqp-0-9-1-reference.html
**Relevance:** AMQP defines the wire protocol for RabbitMQ, including connection lifecycle, acknowledgment modes, and QoS prefetch behavior. This is the authoritative source for message queue consumer requirements.

---

## Connection Lifecycle

> The AMQP connection is a full-duplex connection that is opened and closed using a handshake. The client initiates the connection by sending a protocol header. The server responds with a Connection.Start method. The client must then authenticate and the server sends Connection.Tune with connection limits. The client sends Connection.Open and the server responds with Connection.Open-Ok.

**Key Claim:**
- `msgqueue/connection/lifecycle :: handshake_required = true`
- **Consequence:** Skipping handshake results in protocol violation and connection rejection

---

## Consumer Acknowledgment Modes

> Messages can be acknowledged automatically (basic.consume with no-ack=true) or manually (basic.ack). Automatic acknowledgment means the server assumes the consumer has received and processed the message as soon as it delivers it. Manual acknowledgment means the consumer explicitly tells the server when it has finished processing.

**Key Claim:**
- `msgqueue/consumer/ack_mode :: manual_ack_recommended = true`
- **Consequence:** Auto-ack before processing causes data loss on consumer crashes

---

## QoS Prefetch Count

> The prefetch count specifies a prefetch window in terms of whole messages. The server will send that many messages to the consumer and wait for acknowledgments before sending more. A prefetch count of 0 means "no limit" which can lead to unbounded memory consumption.

**Key Claim:**
- `msgqueue/consumer/prefetch_count :: value_range = 1..100`
- **Consequence:** prefetch_count=0 (unbounded) causes OOM; prefetch_count>100 exhausts broker resources

---

## Connection Heartbeat

> The heartbeat timeout value defines after what period of time the peer TCP connection should be considered unreachable (down) by RabbitMQ and client libraries. This value is negotiated between the client and RabbitMQ server at connection time.

**Key Claim:**
- `msgqueue/connection/heartbeat_interval :: value_range = 10..60`
- **Consequence:** No heartbeat (0) fails to detect dead connections; too short (<10s) causes false positives

---

## Message Redelivery

> A message is redelivered to a consumer if it was delivered with basic.deliver and then rejected with basic.reject or basic.nack with the requeue flag set to true. The redelivered flag is set to true on subsequent deliveries.

**Key Claim:**
- `msgqueue/consumer/requeue_limit :: bounded = true` (3-5 recommended)
- **Consequence:** Unlimited requeues create poison message loops that block queue processing

---

## Extraction Guide

1. **Fetch Specification:**
   ```bash
   # Use WebFetch or manual download
   curl https://www.rabbitmq.com/amqp-0-9-1-reference.html > amqp-spec.html
   ```

2. **Search for Sections:**
   - Connection lifecycle (Connection.Start, Connection.Tune, Connection.Open)
   - Consumer methods (basic.consume, basic.ack, basic.nack, basic.reject)
   - QoS methods (basic.qos, prefetch-count)
   - Heartbeat negotiation
   - Redelivery semantics

3. **Extract MUST/SHOULD Requirements:**
   - Look for normative language (MUST, SHOULD, REQUIRED)
   - Note default values and recommended ranges
   - Document consequences of violations

4. **Map to Concept Paths:**
   ```
   AMQP Connection → msgqueue/connection/*
   AMQP Consumer → msgqueue/consumer/*
   AMQP QoS → msgqueue/consumer/prefetch_count
   ```

5. **Add Consequences:**
   - What breaks if this requirement is violated?
   - What is the user-facing impact? (data loss, OOM, blocking, etc.)
