How do you get the count of dead letter messages in an Azure Service Bus queue?

谁说我不能喝 提交于 2019-12-14 03:59:22

问题


How do you get the count of dead letter messages in an Azure Service Bus queue?

I can get the count in the queue like so ...

var ns = NamespaceManager.CreateFromConnectionString(sbConnectionString);
var queue = ns.GetQueue(queueName);
var count = queue.MessageCount;

But this looks to include both messages in the queue, and also messages in the associated dead letter queue

How can I differentiate between them?


回答1:


Do take a look at MessageCountDetails property in QueueDescription. You will find DeadletterMessageCount there which will provide you the information you're looking for.

var ns = NamespaceManager.CreateFromConnectionString(sbConnectionString);
var queue = ns.GetQueue(queueName);
var count = queue.MessageCount;
var deadletterMessagesCount = queue.MessageCountDetails.DeadletterMessageCount;


来源:https://stackoverflow.com/questions/42932926/how-do-you-get-the-count-of-dead-letter-messages-in-an-azure-service-bus-queue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!