gpt4 book ai didi

asp.net-core - .NET Core Azure servicebusqueue 消息数

转载 作者:行者123 更新时间:2023-12-02 20:26:55 30 4
gpt4 key购买 nike

我目前正在开发一个 .NET Core 项目,其中使用 Microsoft.Azure.Servicebus 版本 1.0 NuGet 包,可在此处找到:https://github.com/Azure/azure-service-bus

我遇到的问题是我没有找到任何方法来获取队列的事件消息数。在 .NET 框架中,使用 ServicebusNamespace.NamespaceManager 引用队列并使用 .ActiveMessageCount,这在过去非常容易。

在这个库中使用 .NET Core 1.1 是否可以通过其他方式实现这一点?

最佳答案

现在可以使用最新版本的Service Bus library (3.1.1):

using Microsoft.Azure.ServiceBus;
using Microsoft.Azure.ServiceBus.Management;

var client = new ManagementClient(connectionString);
var queue = await client.GetQueueRuntimeInfoAsync(queuePath);
var counts = queue.MessageCountDetails;

var subs = await client.GetSubscriptionRuntimeInfoAsync(topic, subscription);
var countForThisSubscription = subs.MessageCount; //// (Comes back as a Long.)

关于asp.net-core - .NET Core Azure servicebusqueue 消息数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46124990/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com