RabbitMQ message time-to-live limits how long a message is eligible for delivery while it waits in a queue. It is different from queue TTL, which governs removal of an unused queue. Expired messages are not necessarily reclaimed at the precise expiry timestamp: messages can wait behind older records, and queue-type behavior affects when they are discarded or dead-lettered. A message can also be delivered around its expiry boundary, so TTL is not a substitute for an application-side deadline check before charging a card or sending a time-sensitive notification. Storage limits, dead-letter routes, and consumer capacity must be planned together.
RabbitMQ TTL: separate message expiry from immediate storage reclamation
Operational decision
A delivery-notification queue holds time-sensitive updates for at most 47 minutes. The worker checks the event's business deadline again before sending because a message already in flight can become stale. The operator pauses consumers, publishes 700 messages with varied expiry times, and watches ready depth and disk bytes after the first messages expire. A dead-letter route sends expired records to an inspection queue only if there is a real review need; otherwise retaining every expired notification can create a second backlog. A replay tool must not send an expired command as if it were new work. It records the original deadline and requires an explicit replacement request.
Message wait TTL: 47 minutes
Business deadline: checked at effect time
Paused-consumer test: 700 synthetic messages
Observe: ready depth, disk bytes, expired/dead-letter counts
Expired command replay: reject without a new business requestCost and verification
Short TTL reduces stale work but can drop legitimate messages during a temporary consumer outage. Long TTL preserves more work but increases storage and recovery cost. Neither choice guarantees instant disk release: segment and queue cleanup behavior can delay reclamation. Test expiry under a paused consumer and a large queue, not only on an empty local queue. Alert on oldest eligible work and on expired-message counts. When applying TTL retroactively, observe the actual drain and cleanup path before using it as an emergency disk-pressure control.
Common Mistakes
- Do not confuse message TTL with queue TTL.
- Do not use TTL as the only business-deadline check.
- Do not promise that expired messages free disk exactly at the expiry timestamp.
Connected lessons
- DevOps: delivery, infrastructure, and reliable operations
- Queue-age scaling: target completion time, not only queue length
- Dead-letter replay: recover failed messages without repeating their effects
- Cloud cost and capacity: assign an owner to each recurring resource
- RabbitMQ publishing: distinguish broker confirmation from queue routing
- RabbitMQ quorum queues: plan node maintenance around majority availability
