azure - 如何在服务总线队列触发函数中将服务总线消息移至死信

标签 azure function servicebus dead-letter queuetrigger

如何通过服务总线队列触发函数将服务总线队列消息移至死信

最佳答案

https://github.com/Azure/azure-webjobs-sdk/issues/1986#issuecomment-433960534

In v3, you can bind to the MessageReceiver class, which exposes methods like DeadLetter, Abaondon, Complete, etc. Example:

public static async Task ProcessMessage(
   [ServiceBusTrigger("myqueue")] string message, int deliveryCount,
   MessageReceiver messageReceiver,
   string lockToken)
{
   . . .
   await messageReceiver.DeadLetterAsync(lockToken);
   . . .
}

In this example, the message is bound as a string and the various message properties including lockToken are bound as params. You can also bind the message as a Message Type and access the requisite message properties from there. In v2 the ServiceBus SDK exposed these message methods directly on the BrokeredMessage class itself, but in the latest version of their SDK those methods no longer exist, meaning you have to bind to MessageReceiver to access them.

编辑时,您还需要将AutoComplete 设置为 false。 https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-service-bus-trigger?tabs=csharp#configuration

关于azure - 如何在服务总线队列触发函数中将服务总线消息移至死信,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61191322/

相关文章:

java - 通过 Java SDK 列出我的 Azure 帐户上的虚拟机

javascript - Bootstrap v5 wp-bootstrap-navwalker 下拉导航栏不起作用

c# - 有没有办法登记 Azure 服务总线中所有队列的所有消息并将它们存储在 json 中?

azure - k8s 使用来自不同命名空间的 secret

azure - 为什么此 az login 命令在 Gitlab CI 中失败?

azure - 您能否重置 Azure MSDN 积分,以便我可以使用其他帐户?

根据 R 中的名称向量删除列

Javascript函数有什么区别吗?

c# - 有关在 .NET 中使用消息队列服务总线的问题

azure - Azure 服务总线上超出了最大传输跃点计数