Bus队列中的死信消息计数

Bus队列中的死信消息计数

本文介绍了如何获取Azure Service Bus队列中的死信消息计数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何获取Azure Service Bus队列中的死信消息计数?

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

如何区分它们?

推荐答案

请查看 MessageCountDetails 属性,位于 QueueDescription .您将找到 DeadletterMessageCount 在那里将为您提供所需的信息.

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;

这篇关于如何获取Azure Service Bus队列中的死信消息计数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

09-06 04:10