问题
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