Azure Functions - 根据事件类型阻止处理 Azure 服务总线消息

Azure Functions - Block processing of Azure Service Bus messages based on event type

我是 azure 的新手,.net framework.I 有一个 Azure 函数 (AF),它由 Azure 服务总线 messages.so 根据我们必须处理收到的消息的事件类型触发 例如事件类型:com.df.vc2.core.employee.add

如果事件类型与上述不同,则不应处理

这可以在配置级别完成吗?这是如何实现的

您不能使用配置来做到这一点,据我所知,无法设置某种排除列表。但是,您可以使用代码来完成。默认情况下,当函数运行时,它会在成功处理后自动完成消息。这是基于 AutoComplete 中显示的配置设置 the docs

如果将其设置为 false,则可以这样编写代码,以便仅完成函数中要处理的消息。其他消息将保持不变。

If set to true, the trigger completes the message automatically if the function execution completes successfully, and abandons the message otherwise.

When set to false, you are responsible for calling MessageReceiver methods to complete, abandon, or deadletter the message. If an exception is thrown (and none of the MessageReceiver methods are called), then the lock remains. Once the lock expires, the message is re-queued with the DeliveryCount incremented and the lock is automatically renewed.