Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Azure WebJobs SDK Service Bus DeadLetter queue

When using the WebJobs SDK what is the proper way to move a BrokeredMessage to the deadletter queue? Usually I would just call msg.DeadLetter(). However, the SDK takes care of managing the life cycle of the brokered message. It will call msg.Complete() if the method returns successful, and it will retry the message if an exception occurs. I need the 3rd case of telling the ServiceBus queue to move the message to the deadletter queue as it is a bad message.

like image 712
Tod Cunningham Avatar asked Mar 18 '23 05:03

Tod Cunningham


1 Answers

You can explicitly deadletter the service bus queue and trigger a function when the message is dead lettered.

public static void ProcessSBQueueMessage(
[ServiceBusTrigger("inputqueue")] BrokeredMessage inputText)
{
    inputText.DeadLetter("Webjobs", "webjobsdescription");
    Console.WriteLine(inputText);
}

public static void ProcessSBDeadLetterQueueMessage(
[ServiceBusTrigger("inputqueue/$DeadLetterQueue")] BrokeredMessage inputText)
{
    Console.WriteLine(inputText);
}
like image 198
pranav rastogi Avatar answered Mar 27 '23 17:03

pranav rastogi