Azure WebJobs SDK Service Bus DeadLetter queue

When using the WebJobs SDK, what is the proper way to move the BrokeredMessage to the miscast queue? I usually just call msg.DeadLetter (). However, the SDK takes care of managing the lifecycle of the broker message. It will call msg.Complete () if the method returns successfully, and it will retry the message if an exception is thrown. I need a third case to tell the ServiceBus queue to move the message to the dead queue as this is a bad message.

+3


source to share


1 answer


You can explicitly program the Service Bus queue and call the function when the message is dead.



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);
}

      

+5


source







All Articles