0

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?

Peter Bons
  • 26,826
  • 4
  • 50
  • 74
Spartan 117
  • 520
  • 2
  • 6
  • 21
  • Does this answer your question? [Getting Message Stats in Azure Service Bus](https://stackoverflow.com/questions/38462261/getting-message-stats-in-azure-service-bus) – Ecstasy Jun 28 '22 at 07:32
  • [Determining how many messages are on the Azure Service Bus Queue/Topic](https://stackoverflow.com/a/60210207/15969115) – Ecstasy Jun 28 '22 at 07:34
  • 2
    @DeepDave-MT No, because that just lets me know about the number of messages on the topic/queue, not the number of times a particular message has been on a queue/topic. – Spartan 117 Jun 28 '22 at 17:16

1 Answers1

1

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

Peter Bons
  • 26,826
  • 4
  • 50
  • 74