I am currently working on a .NET Core project where I use the Microsoft.Azure.Servicebus version 1.0 NuGet package found here: https://github.com/Azure/azure-service-bus
The problem I have is that I haven't found any method to get a queue's number of active messages. This used to be pretty easy with .NET framework using the ServicebusNamespace.NamespaceManager, referring to a queue and use the .ActiveMessageCount.
Is this possible in some other way in this library with .NET Core 1.1?
It is now possible using the latest version of the 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.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With