Search code examples
c#azureazureservicebusazure-servicebus-topicsazure-servicebus-subscriptions

Getting Message Stats in Azure Service Bus


I am writing a utility to monitor our Azure Service Bus Topics and Subscriptions.

I can get the Topic details, such as name, queued message count and dead-letter message count, but I would like to get the number of messages that have been processed.

Here is the code I am using:

var sub = namespaceManager.GetSubscription(topicPath, subscriptionName);

var name = sub.Name;
var pending= sub.MessageCountDetails.ActiveMessageCount;
var deadletter = sub.MessageCountDetails.DeadLetterMessageCount

It seems that GetSubscription does not include any properties to get the number of messages processed.

Has anyone tried to do this before?


Solution

  • It is possible to fetch the Total Count of Messages in a Topic, Incoming Messages, Outgoing Messages with the help of the latest Azure Monitor Metrics. In your case, count of Outgoing messages will be the number of processed messages.