如何正确暂停Rebus从接收消息?

时间:2019-03-25 16:07:09

标签: c# rebus bus

我在here中描述了类似的情况,但由于已在该站点上注册而无法在此处发表评论。 在大多数情况下,使用SetNumberOfWorkers(0)“暂停”的解决方法是可行的。但是,如果在冗长的消息处理程序中调用An error occurred when attempting to complete the transaction context Rebus.Exceptions.RebusApplicationException: Could not complete message with ID <...> and lock token <...> ---> Microsoft.Azure.ServiceBus.MessageLockLostException: The lock supplied is invalid. Either the lock expired, or the message has already been removed from the queue.,则在消息处理程序的末尾会收到以下错误:

"Worker Rebus 1 worker 1 stopped"

请注意,尽管处理程序仍在运行,但在调用SetNumberOfWorkers(0)之后几乎所有工作人员都会收到Box Collider 2d消息。

使工作人员数量恢复正常后,所有其他消息在处理程序末尾都会引发类似的错误。

任何建议如何正确处理暂停暂停?

(我需要暂停,因为我的微服务需要定期更新一些资源,并且处理程序在更新期间无法运行)

0 个答案:

没有答案