Do messages in dead letter queues in Azure Service Bus expire?
I have these queue settings:
var queueDescription = new QueueDescription("MyTestQueue")
{
RequiresSession = false,
DefaultMessageTimeToLive = TimeSpan.FromMinutes(1),
EnableDeadLetteringOnMessageExpiration = true,
MaxDeliveryCount = 10
};
namespaceManager.CreateQueue(queueDescription);
When I place some messages in a Azure Service Bus message queue (not queues from Azure Storage) and don't consume them (ever), they'll be moved to the dead letter queue automatically.
However, if I have no consumer for the dead letter queue either, will the messages ever be deleted from the dead letter queue or will they stay there forever? (Is there some official documentation stating how this is supposed to work?)
In my trials, I placed 3 messages in the queue. They were dead lettered after 2 minutes or so. They remained in the dead letter queue for at least a day and weren't removed.
Although calling NamespaceManager.GetQueueAsync() gave me the values above (notice how MessageCount
is still 3
but DeadLetterMessageCount
is strangely 0
), I could still receive the messages from the dead letter queue. (So they weren't removed from the queue.)
Sebastian your observation is correct, in that messages once placed in the DeadLetter sub-queue never expire. They will be available there forever until removed explicitly from the DeadLetter sub-queue. In the above error regarding the tooling/api it could be a refresh issue? The call to GetQueueAsync() needs to be made after the messages have been dead-lettered which is not a deterministic time, say if you had a queue with a thousand messages that were expired but that Queue was not being used (send/receive operations) then the count may still return as Active until some operations are performed.