0

I have created RabbitMQ queues with x-expires policies using EasyNetQ (ISubscriptionConfiguration.WithExpires). I am experiencing situations where queues that have consumers expire and get deleted, unexpectedly ending my subscription to the queue.

The official RabbitMQ docs on Queue TTL specify that

Queues will expire after a period of time only when they are not used (e.g. do not have consumers).

It also defines "unused" as meaning

the queue has no consumers, the queue has not been recently redeclared (redeclaring renews the lease), and basic.get has not been invoked for a duration of at least the expiration period.

Based on this, I would expect that a queue would only expire if it has no consumers. Meaning that, even if a queue has not gotten a message for the duration of the expiration period, a consumer of the queue would prevent it from expiring.

Is my interpretation of the docs incorrect? Why would my queues expire if they have a consumer?

Ryan K.
  • 67
  • 1
  • 10
  • Your interpretation is correct. How long is the expiration, are you sure there's not a network hickup? – Wiebe Tijsma May 11 '21 at 08:26
  • My `x-expires` value is `28800000` (8 hours), so I suppose a network hiccup would be possible in such a timeframe. When I last experienced this, I double-checked whether the connection that spawned the consumers still existed, and it did. I also have `auto-delete` enabled. Is there a chance that a queue created by EasyNetQ could get auto-deleted by a network hiccup? – Ryan K. May 11 '21 at 18:34
  • Yes, auto-delete will immediately delete the queue when all consumers are disconnected, so it's basically an x-expires=0. – Wiebe Tijsma May 12 '21 at 07:16
  • I have the same problem, I do not have autodelete enabled, just the WithExpires option, there is still a connection to the MQServer, they are on the same physical machine, so not a network issue. But the queue is removed from the server after the expires period, even though my program is still listening for messages. – Mark LFT Aug 19 '21 at 03:31

1 Answers1

0

Remove auto-delete from your policies or queue declarations.

Auto-delete will immediately delete the queue when all consumers are disconnected, so it's basically an x-expires=0 (immediately after disconnect).

Wiebe Tijsma
  • 10,173
  • 5
  • 52
  • 68