Why messages expire
A time to live or TTL sets how long a message stays valid. After it expires the message should not be processed, because acting on stale data can be wrong or wasteful. A live location ping or a flash sale notice loses value quickly.
Where expiry applies
- Per message TTL: each message carries its own deadline.
- Per queue TTL: every message in a queue inherits the same maximum age.
- Retention TTL: a log keeps messages only for a window, then trims old segments.
What happens at expiry
An expired message is either dropped silently or routed to a dead letter queue for visibility. Routing expired messages to a DLQ helps teams notice when consumers fall too far behind.
Expiry versus retention
Per message TTL is about correctness, do not act on stale data. Log retention is about storage, reclaim disk after a time window regardless of consumption.
Flow
Key idea
TTL caps how long a message stays valid, preventing stale data from being processed and bounding how long it occupies the broker.