Determining how many messages are on the Azure Service Bus Queue

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

    I ran into this same problem trying to get the count from the dead letter queue. It looks like the deadletterqueue doesn't allow you to get a count directly, you get it from the MessageCountDetails of the normal Queue.

    string connectionString = ConfigurationManager.AppSettings["Microsoft.ServiceBus.Connstr"].ToString();
    NamespaceManager nsmgr = Microsoft.ServiceBus.NamespaceManager.CreateFromConnectionString(connectionString);
    return nsmgr.GetQueue(QueueName).MessageCountDetails.DeadLetterMessageCount;
    

提交回复
热议问题