【问题标题】:What's the equivalent of NamespaceManager.GetQueue.MessageCount in the new NET Standard Microsoft.Azure.ServiceBus?新的 NET 标准 Microsoft.Azure.ServiceBus 中的 NamespaceManager.GetQueue.MessageCount 等价物是什么?
【发布时间】:2020-10-08 19:55:52
【问题描述】:

新的 NET 标准 Microsoft.Azure.ServiceBus 中 NamespaceManager 的等价物是什么?

我使用 WindowsAzure.ServiceBus 来做一些事情,比如计算队列中的消息...

var namespaceManager = NamespaceManager.CreateFromConnectionString(SbConnectionString);
var count = namespaceManager.GetQueue(queueName).MessageCount;

转移到新的 Microsoft.Azure.ServiceBus .NET 标准库,但虽然它有 QueueClient 和 TopicClient 等类,但它没有任何 NamespaceManager

如何在新的 .NET Standard 库中进行消息计数?

【问题讨论】:

    标签: azure azureservicebus .net-standard


    【解决方案1】:

    提供更新:

    这现已在Microsoft.Azure.ServiceBus.Management; 命名空间下实现并可用。

    NamespaceManager 现在称为 ManagementClient,并且(大致)具有相同的可用端点。

    这是class itself 作为pull request to merge it into the main repository 的一部分。

    【讨论】:

      【解决方案2】:

      你不能。

      新 API 不支持阅读消息计数。您必须使用 Azure Monitor API 来获取它们。

      Reading Azure Service Bus Metrics 中了解为什么会这样以及如何使用 Azure Monitor。

      【讨论】:

        【解决方案3】:

        您可以读取队列消息计数:

        var managementClient = new ManagementClient(connectionString);
        (await managementClient.GetQueueRuntimeInfoAsync("name")).MessageCount;
        

        【讨论】:

          猜你喜欢
          • 2011-04-16
          • 2014-11-22
          • 2022-06-12
          • 2010-10-02
          • 1970-01-01
          • 1970-01-01
          • 2012-04-07
          • 2011-06-05
          相关资源
          最近更新 更多