Determining how many messages are on the Azure Service Bus Queue

后端 未结 9 864
难免孤独
难免孤独 2020-12-09 15:52

I know there is a way to determine the number of messages (or approximate number) in the Azure Queue (Store Account); however is there a way to query for the number of pendi

9条回答
  •  难免孤独
    2020-12-09 16:40

    Based off what Joseph had as an answer I came up with, but for Topics and Subscriptions.

    public async Task GetCounterMessages()
            {
                var client = new ManagementClient(ServiceBusConnectionString);    
                var subs = await client.GetSubscriptionRuntimeInfoAsync(TopicName, SubscriptionName);
                var countForThisSubscription = subs.MessageCount;  //// (Comes back as a Long.)               
                return countForThisSubscription;
            }
    

提交回复
热议问题