Azure / azure-service-bus-dotnet

☁️ .NET Standard client library for Azure Service Bus
https://azure.microsoft.com/services/service-bus
Other
235 stars 120 forks source link

Feature request: Need to be able to obtain number of messages in queues and topics in ServiceBus from .NET Core project #620

Closed Andrey-Anatolyevich closed 5 years ago

Andrey-Anatolyevich commented 5 years ago

Actual Behavior

  1. Have no way of obtaining count of how many messages there is in queues and topics' subscriptions

Expected Behavior

  1. Need to be able to get number of messages in queues and topics using this library on top of .NET Core project

Versions

Comment: It is so frustrating to see such basic functionality cut for "So much loved by Microsoft" NetStandard compatible library as opposed to WindowsAzure.ServiceBus, which is for WINDOWS only! Guys, it pisses off and pushes faar-far away from any of your products.

SeanFeldman commented 5 years ago

Don't get frustrated @Andrey-Anatolyevich. You can find message counts under ManagementClient.GetQueueRuntimeInfoAsync and similar. Cheers.

Andrey-Anatolyevich commented 5 years ago

@SeanFeldman, Thank you for fast response. Also, could you advice a code snippet by a chance? This is what I see in suggested class & method result: image It doesn't look like the result has any details on queue size.

I feel like I'm missing something big and obvious whereas working with WindowsAzure.ServiceBus was very smooth and intuitive.

SeanFeldman commented 5 years ago

What you get back is a Task (promise), not the result. Being an asynchronous method (notice Async() at the end), you have to await for the call to get the results. Hope that helps.

Andrey-Anatolyevich commented 5 years ago

image

@SeanFeldman, Thank you. I got the counts.

Snippet for those, who might struggle as well: var mgmtClient = new ManagementClient(connectionString); var runtimeInfo = mgmtClient.GetQueueRuntimeInfoAsync("[QUEUE-NAME]").GetAwaiter().GetResult(); var activeCount = runtimeInfo.MessageCountDetails.ActiveMessageCount; var deadletterCount = runtimeInfo.MessageCountDetails.DeadLetterMessageCount; var transferCount = runtimeInfo.MessageCountDetails.TransferMessageCount;