本文介绍了Azure WebJobs SDK服务总线DeadLetter队列的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

使用WebJobs SDK时,将BrokeredMessage移至死信队列的正确方法是什么?通常我只打电话给msg.DeadLetter().但是,SDK负责管理代理消息的生命周期.如果该方法返回成功,它将调用msg.Complete(),如果发生异常,它将重试该消息.我需要告诉ServiceBus队列将消息移动到Deadletter队列的第三种情况,因为它是错误消息.

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.

推荐答案

您可以显式使服务总线队列死信,并在消息用死信表示时触发功能.

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

这篇关于Azure WebJobs SDK服务总线DeadLetter队列的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-04 08:08
查看更多