Azure WebJobs SDK Service Bus DeadLetter queue

一曲冷凌霜 提交于 2019-12-12 16:06:53

问题


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.


回答1:


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


来源:https://stackoverflow.com/questions/26371091/azure-webjobs-sdk-service-bus-deadletter-queue

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!