CQ with no consumers not expiring messages (via message-ttl) but getting a single message via WebUI reproducibly triggers an expire #10697
-
Describe the bugI am running a RabbitMQ cluster with 3 nodes on Ubuntu Jammy (22.04 LTS) wíth RabbitMQ at 3.12.13 and Erlang 26.2.2. The queue receives messages from various clients, but there might be no consumers for a longer period of time.
The policy actually does become effective for the queue: but no messages are expired and they are building up over the configured message expire period. Strangely though, if one uses the WebUI to get a single message, the queue applied the message-ttl and expires all the older messages. This can be seen "nicely" in the WebUI and Prometheus metrics: Around the time the issue started, RabbitMQ started logging
I found and read https://www.rabbitmq.com/docs/runtime#distribution-buffer, but did not make any adjustments yet. Reproduction stepsWe tried to reproduce the issue in another environment, but were not really successful.
Expected behaviorApplying a message-ttl if 4 hours to a (quorum) queue is expected for that queue to expire them, no matter if there are consumers or not. Additional context
|
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 4 replies
-
This is a documented behavior, messages are expired when they reach the head of the queue and a consumption. There are no plans to change this. Expired messages will not be delivered to consumers, as documented, and that's the key objective. Queues without consumers is a scenario RabbitMQ does not optimize for. If you need to store data for a period of time with exclusively time-based expiration and with sporadic consumer availability, streams are a better option. Inter-node communication buffer is completely irrelevant to message TTL. |
Beta Was this translation helpful? Give feedback.
-
@michaelklishin First of all thanks again for your time and thoughts on this matter! For clarity, the use case I have is OpenStack (oslo.messaging), but could be any other conglomerate of services, that has optional components and in case they are not installed / used certain messages to certain queues are simply not consumed. Yes, it might be best to stop sending them, which is possible, but I'd also like to configure safety net on the broker side that ensures no message lives forever (and requires me to purge queues at some point to get rid of them).
But the queues in question might constantly receive messages. Will a queue TTL then work at all?
Yes my idea was just to trigger the existing message-TTL expiry mechanism that apparently is also working if I fetch a single message (as per my initially reported issue). I was rather looking for something I could do via Another point which I'd like to clarify is the wording in the documentation as you agreeably receive questions about message-ttl not working as expected more often than necessary. So https://www.rabbitmq.com/docs/ttl#message-ttl-dead-lettering states:
What does that mean in relation to having no consumers? Will a quorum queue reliably expire messages which all have a message-ttl set from the beginning (so not retroactively)? Cause we have a cluster that seems to happily expire messages with no consumers for weeks now. But I did open the issue because it stopped working somewhere sometime. So I'd just like to clarify the conditions on message expiry and what |
Beta Was this translation helpful? Give feedback.
This is a documented behavior, messages are expired when they reach the head of the queue and a consumption.
There are no plans to change this. Expired messages will not be delivered to consumers, as documented, and that's the key objective. Queues without consumers is a scenario RabbitMQ does not optimize for. If you need to store data for a period of time with exclusively time-based expiration and with sporadic consumer availability, streams are a better option.
Inter-node communication buffer is completely irrelevant to message TTL.