从 Azure 服务总线在 Azure Web 作业中多次收到相同的消息

Same Message received multiple time in Azure Web Job from Azure Service Bus

我有一个 Azure 服务总线 运行。每当新消息填充到 Queue 中时,它就会被发送到 Azure 服务总线 Web 作业。我看到同一条消息多次出现,有时会给出这样的错误消息。

The lock supplied is invalid. Either the lock expired, or the message has already been removed from the queue. azure web job service bus

背后的原因是什么,如何解决?

此错误表明在 webjob 中执行的工作花费的时间超过了为消息提供的配置锁定时间。队列中有一个 属性,MaxLockDuration,默认为 60 秒,不能超过 5 分钟。如果可以在 5 分钟内完成处理,则需要增加队列的锁定持续时间,或者更改处理消息的方式。一种选择是重新锁定,但我不建议走那条路,因为它不能保证操作。