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

标签 asp.net-core .net-core azureservicebus azure-servicebus-queues

我目前正在开发一个 .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/

相关文章:

.net-core - 如何在Visual Studio中发布.NET Core项目包括 View 和区域文件夹

c# - Windows Azure MessageLockLostException

Azure 服务总线订阅和主题大小

c# - Tag Helpers 在 ViewComponent 中没有正确呈现

c# - 在 ViewComponent : This async method lacks 'await' operators and will run synchronously

c# - 异常过滤在 ASP .NET Core 2.0 中不起作用

wcf - .NET 中的 Azure 服务总线队列集成方法

c# - 如何为 ASP.NET 5 应用程序设置语言环境?

c# - .net core classlibrary调用.net framework类库

.net-core - dotnet core 1.0.1 Preview2 在 dotnet 测试中卡住/挂起?