← Debugging Guides

阅读中文版本

RabbitMQ — message TTL expired before consumption

RabbitMQ drops messages because the queue or message TTL expires before a consumer processes them, causing silent message loss under high load.

intermediatedebuggingrabbitmqttl

Symptoms

  • Messages disappear from the queue without being consumed
  • Dead-letter queue receives expired messages
  • Consumer logs show no processing for messages that were published

Possible causes

  • The queue TTL is too short for the current consumer processing rate
  • Consumers are slow or offline, so messages wait longer than the TTL
  • The message-level TTL overrides the queue TTL with a shorter value

Diagnosis steps

Check queue arguments and TTL

rabbitmqctl list_queues name arguments messages

Interpretation

Shows the x-message-ttl argument and message count per queue.

Monitor consumer rates

rabbitmqctl list_consumers

Interpretation

Compare consumer count and processing rate against publish rate.

Root cause

The message TTL expires before a consumer picks up the message, so RabbitMQ removes it from the queue and optionally routes it to a dead-letter exchange.

Fix

Increase the queue or message TTL, add more consumers, or route expired messages to a dead-letter queue for retry. Monitor consumer lag to detect saturation.

Verify the fix

Publish a message and confirm it is consumed within the TTL; verify expired messages go to the DLQ if configured.

Symptom walkthrough

RabbitMQ drops messages because the queue or message TTL expires before a consumer processes them, causing silent message loss under high load. The error appears in production but may not surface in local development because the conditions that trigger it depend on the deployment environment or runtime configuration. Understanding the full symptom set helps distinguish this issue from similar errors.

Diagnosis in practice

Follow the diagnosis steps in the frontmatter to isolate the cause. Each step includes a command and an interpretation of the output. The goal is to narrow down whether the issue is in the configuration, the runtime, or the application code. Reproduce the error in a minimal setup before applying a fix.

Root cause

The message TTL expires before a consumer picks up the message, so RabbitMQ removes it from the queue and optionally routes it to a dead-letter exchange.

Fix

Increase the queue or message TTL, add more consumers, or route expired messages to a dead-letter queue for retry. Monitor consumer lag to detect saturation. After applying the fix, monitor the system to confirm the error does not recur under load or in different environments.

Verification

Publish a message and confirm it is consumed within the TTL; verify expired messages go to the DLQ if configured. If the verification passes, the fix is confirmed; if not, re-examine the diagnosis steps for missed contributing factors.

Diagnostic commands

Run these commands to reproduce and diagnose the issue:

rabbitmqctl list_queues name arguments messages
rabbitmqctl list_consumers