Determining how many messages are on the Azure Service Bus Queue

后端 未结 9 844
难免孤独
难免孤独 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:19

    I've spent good 2 hours digging through docs to get that and for people using .net core and Microsoft.Azure.ServiceBus nuget package, code looks like that:

    var managementClient = new ManagementClient("queue connection string"));
    var runtimeInfo = await managementClient.GetQueueRuntimeInfoAsync("queueName");
    
    var messagesInQueueCount = runtimeInfo.MessageCountDetails.ActiveMessageCount;
    

    Aparently you get the information about all Counts(including deadletter, active, etc.) from QueueRuntimeInfo object instead of old QueueDescription object.

提交回复
热议问题