Home > Back-end >  Determine the number of times a message has been on the Azure Topic
Determine the number of times a message has been on the Azure Topic

Time:06-29

I currently have an azure service bus topic that I'm subscribed to and want to implement retry logic based on the number of times a message has been on the topic. Is there a method in the Microsoft.Azure package that provides us with this information? Do I need to configure the message that is received by the C# service bus subscriber client to send that information? Do I need to change anything on the topic itself?

CodePudding user response:

You can use the Message.SystemProperties.DeliveryCount property for that:

Number of deliveries that have been attempted for this message. The count is incremented when a message lock expires, or the message is explicitly abandoned by the receiver. This property is read-only.

(source)

If you ever switch to the newest SDK, Azure.Messaging.ServiceBus, it is the ProcessMessageEventArgs.Message.DeliveryCount property, see the docs

  • Related