Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the equivalent of NamespaceManager.GetQueue.MessageCount in the new NET Standard Microsoft.Azure.ServiceBus?

What's the equivalent of NamespaceManager in the new NET Standard Microsoft.Azure.ServiceBus?

I've used WindowsAzure.ServiceBus to do things like count messages in a queue ...

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

Moving over to the new Microsoft.Azure.ServiceBus .NET Standard library, but whilst it's got classes like QueueClient and TopicClient, it's not got any NamespaceManager

How can you could do message counts in the new .NET Standard library?

like image 883
SteveC Avatar asked Jan 10 '18 16:01

SteveC


2 Answers

You can't.

The new API doesn't support reading message counts. You'd have to use Azure Monitor API to get them.

Read why that's that case and how to work with Azure Monitor in Reading Azure Service Bus Metrics.

like image 44
Mikhail Shilkov Avatar answered Nov 13 '22 08:11

Mikhail Shilkov


To provide an update:

This is now implemented and available under the Microsoft.Azure.ServiceBus.Management; namespace.

NamespaceManager is now called ManagementClient and has (roughly) the same endpoints available.

Here's the class itself as part of the pull request to merge it into the main repository.

like image 128
James Gould Avatar answered Nov 13 '22 09:11

James Gould