3

I want to handle dead letters of my azure service bus queue. For this I thought I could use a azure function with a ServiceBusTrigger:

[FunctionName("DoSomethingWithDeadLetters")]
public static async Task DoSomething(
    [ServiceBusTrigger("myqueue/$DeadLetterQueue", Connection = "ServiceBusConnection")]
    Message deadLetter)

Unfortunately with this the messages are processed in PeekLockMode.

If my code is faulty and the function fails with an exception the dead-letter-message is abandoned. The ServiceBusTrigger will start the function again short time later... of course it will fail due to the same exception and abandon the message again... a endless loop is born.

Is it possible to use the ServiceBusTrigger with ReceiveAndDelete mode? This would be sufficient for my dead letter handling.

MMS1980
  • 31
  • 1
  • 1
    I don't see that option in ServiceBusTrigger but you can call "deadLetter.Complete()" method before executing any business logic or put this link in "try-finally block" to execute always. – Pankaj Rawat May 09 '19 at 09:47
  • Should not be an endless loop. What is your queue's [Max Delivery Count](https://stackoverflow.com/questions/44285828/azure-service-bus-queue-message-handling#:~:text=You%20could%20specify%20the%20Maximum,bus%20queue%20on%20Azure%20Portal.)? – PatrickSteele Jun 03 '20 at 16:06

0 Answers0