0

I am using azure.messaging.servicebus sdk, and I would like to log messages that are going to dead-letter and also inform other services about it. Can't seem to find a handler in the object MessageProcessor for this behavior. I thought of doing my own checks of "DeliveyCount == MaxDeliveryCount" But I can't find the MaxDeliveryCount on any of the servicebus objects (DeliveryCount is there).

Am I missing something? The only solution I can think of is setting my own Max in config and set the amount in azure to be at least that.

Arik Shapiro
  • 33
  • 1
  • 7

1 Answers1

0

If you you are explicitly calling DeadLetterMessage() for some of the messages you can log it every time the method is called, for system dead lettered messages (TTL, delivery count) you can use the Errorhandler to react to MaxDeliveryCountExceededExceptionMessage Error handler, then you can log the message when handling the exception.

Alternatively, the MessageReceived class has a current delivery count property Documentation

In case you don´t need to log specific messages but rather react when there are messages there in the dead letter queue, you can use the service bus administration client to get the current count of messages in the DLQ, then react based on that and have other services start pulling all those from DLQ. Administration client

Jdresc
  • 618
  • 1
  • 5
  • 11
  • I've tried using the error handler, it doesn't call it on a system thrown MaxDeliveryCountExceededExceptionMessage. What I've tried is throwing an Exception in the Message handler which increases the delivery count, the exception I threw called the Error handler but it was never called for the count exceeded. – Arik Shapiro Oct 03 '21 at 08:21