Azure WebJobs 和 ServiceBusTrigger

Azure WebJobs and ServiceBusTrigger

Azure WebJobs SDK ServiceBusTrigger 的病毒消息处理是如何工作的?我希望将已出队超过 'x' 次的服务总线队列消息推送到不同的 ServiceBus(或)存储队列

联机文档 here and here and SDK Samples from here 没有关于 ServiceBusTrigger 如何处理有害消息的示例。这项工作正在进行中吗?

我尝试使用 dequeueCount 参数实现自定义毒消息处理,但它看起来不支持 ServiceBusTriggers,因为我收到运行时异常 {"Cannot bind parameter 'dequeueCount' when using this trigger."}

public static void ProcessMessage([ServiceBusTrigger(topicName: "abc", subscriptionName: "abc.gdp")] NotificationMessage message,
            [Blob("rox/{PayloadId}", FileAccess.Read)] Stream blobInput, Int32 dequeueCount)
        {
            throw new ArgumentNullException();
        }

看起来 WebJobs 目前在内部处理这个问题。

参考:How to use Azure Service Bus with the WebJobs SDK

特定部分:

How ServicebusTrigger works

The SDK receives a message in PeekLock mode and calls Complete on the message if the function finishes successfully, or calls Abandon if the function fails. If the function runs longer than the PeekLock timeout, the lock is automatically renewed.

Service Bus does its own poison queue handling, so that is neither controlled by, nor configurable in, the WebJobs SDK.

Additional Reference

Poison message handling can't be controlled or configured in Azure Functions. Service Bus handles poison messages itself.

虽然您无法获取 ServiceBus 消息的 dequeueCount 属性,但您始终可以绑定到 BrokeredMessage 而不是 NotificationMessage 并从中获取 属性它。

为了补充 Brendan Green 的回答,WebJobs SDK 在处理失败的消息上调用 Abandon,在最大重试次数后,服务总线将这些消息移至死信队列。可以在服务总线 -> 队列 -> 属性中更改定义消息何时移入死信队列的属性,例如最大传递计数、生存时间和 PeekLock 持续时间。

您可以在此处找到有关 SB 死信队列的更多信息:https://docs.microsoft.com/en-us/azure/service-bus-messaging/service-bus-dead-letter-queues