[英]Do messages in dead letter queues in Azure Service Bus expire?
Do messages in dead letter queues in Azure Service Bus expire? Azure Service Bus中死信队列中的邮件是否过期?
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. 当我将一些消息放入Azure Service Bus消息队列(而不是来自Azure存储的队列)并且不消耗它们时(永远),它们将自动移动到死信队列。
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. 在我的试验中,我在队列中放置了3条消息 。 They were dead lettered after 2 minutes or so.
他们在2分钟左右就死了。 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. 虽然调用NamespaceManager.GetQueueAsync()给了我上面的值(注意
MessageCount
仍然是3
但DeadLetterMessageCount
奇怪地为0
),我仍然可以从死信队列中接收消息。 (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. Sebastian你的观察是正确的,因为一旦置于DeadLetter子队列中的消息永不过期。 They will be available there forever until removed explicitly from the DeadLetter sub-queue.
它们将永远在那里可用,直到从DeadLetter子队列中显式删除。 In the above error regarding the tooling/api it could be a refresh issue?
在上面关于工具/ api的错误中,它可能是一个刷新问题? 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.
GetQueueAsync()的调用需要在消息被称为死信之后进行,这不是一个确定的时间,例如,如果你有一个队列,其中有一千条消息已经过期但是Queue没有被使用(发送/接收操作) )然后计数可能仍然作为活动返回,直到执行某些操作。
After doing some research I stumbled over a fact I missed completely: 在做了一些研究后,我偶然发现了一个我完全错过的事实:
Messages can expire even when dead lettering is disabled. 即使禁用了死信,消息也会过期。
When messages expire while dead lettering is disabled (which is the default), they'll just get deleted. 当消息过期而禁用死信(这是默认设置)时,它们将被删除。
So, Microsoft's reasoning for not auto-deleting messages from the dead letter queue is probably: 因此,微软推断不能从死信队列中自动删除邮件的原因可能是:
If you're enabling dead lettering, you explicitly want expired message not to be thrown away but stored somewhere else (the dead letter queue) so that you can review them. 如果您正在启用死信,那么您明确地希望过期的消息不会被丢弃,而是存储在其他地方(死信队列),以便您可以查看它们。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.