Azure 服务总线自动更新超时
Azure ServiceBus AutoRenewTimeout
我正在通过 .net SDK 使用 Azure 服务总线队列。 OnMessageHandler/OnMessageOptions 上有一个名为 "AutoRenewTimeout" 的标志,但似乎对该值的实际含义感到困惑。
这里的官方文档 https://msdn.microsoft.com/en-us/library/microsoft.servicebus.messaging.onmessageoptions.aspx 建议 AutoRenewTimeout 应该大于队列锁定持续时间。
Gets or sets the maximum duration within which the lock will be renewed automatically. This value should be greater than the longest message lock duration; for example, the LockDuration Property.
这似乎表明 AutoRenewTimeout 或多或少是处理消息应该花费的最长时间。例如如果您的锁定持续时间为 1 分钟,自动更新超时为 5 分钟,则消息将总共更新 5 次,然后放弃并再次在队列中可见。还有其他 Whosebug 答案证实了这种情况,例如
To handle long message processing you should set AutoRenewTimeout == 10 min (in your case). That means that lock will be renewed during these 10 minutes each time when LockDuration is expired.
So if for example your LockDuration is 3 minutes and AutoRenewTimeout is 10 minutes then every 3 minute lock will be automatically renewed (after 3 min, 6 min and 9 min) and lock will be automatically released after 12 minutes since message was consumed.
然而,在更多研究中,我偶然发现了一条旧推文 (https://twitter.com/clemensv/status/649940087267041284),该推文看起来像是 Microsoft 的消息传递首席架构师。在此推文中,似乎暗示 AutoRenewTimeout 是调用 "RenewLock" 方法的间隔。
it's the interval in which https://msdn.microsoft.com/en-us/library/microsoft.servicebus.messaging.brokeredmessage.renewlock.aspx is called on a message while the callback is active
因此,例如,如果您的锁定持续时间为 1 分钟,则 AutoRenewTimeout 应为 30 秒左右,以确保消息锁定在释放之前得到更新。
在我自己的测试中,我倾向于前者是正确的,但这条推文让我怀疑这个事实,也许我不知道 AutoRenewTimeout 的完整用法
你的测试是正确的。
AutoRenewTimeout
将允许延长处理时间超过 LockDuration
w/o 增加 DeliveryCount
。它应该设置为最大处理时间回调。将其读取为等待处理回调完成的时间范围。在那之后 OnMessage API 将不会发出更新。
我正在通过 .net SDK 使用 Azure 服务总线队列。 OnMessageHandler/OnMessageOptions 上有一个名为 "AutoRenewTimeout" 的标志,但似乎对该值的实际含义感到困惑。
这里的官方文档 https://msdn.microsoft.com/en-us/library/microsoft.servicebus.messaging.onmessageoptions.aspx 建议 AutoRenewTimeout 应该大于队列锁定持续时间。
Gets or sets the maximum duration within which the lock will be renewed automatically. This value should be greater than the longest message lock duration; for example, the LockDuration Property.
这似乎表明 AutoRenewTimeout 或多或少是处理消息应该花费的最长时间。例如如果您的锁定持续时间为 1 分钟,自动更新超时为 5 分钟,则消息将总共更新 5 次,然后放弃并再次在队列中可见。还有其他 Whosebug 答案证实了这种情况,例如
To handle long message processing you should set AutoRenewTimeout == 10 min (in your case). That means that lock will be renewed during these 10 minutes each time when LockDuration is expired.
So if for example your LockDuration is 3 minutes and AutoRenewTimeout is 10 minutes then every 3 minute lock will be automatically renewed (after 3 min, 6 min and 9 min) and lock will be automatically released after 12 minutes since message was consumed.
然而,在更多研究中,我偶然发现了一条旧推文 (https://twitter.com/clemensv/status/649940087267041284),该推文看起来像是 Microsoft 的消息传递首席架构师。在此推文中,似乎暗示 AutoRenewTimeout 是调用 "RenewLock" 方法的间隔。
it's the interval in which https://msdn.microsoft.com/en-us/library/microsoft.servicebus.messaging.brokeredmessage.renewlock.aspx is called on a message while the callback is active
因此,例如,如果您的锁定持续时间为 1 分钟,则 AutoRenewTimeout 应为 30 秒左右,以确保消息锁定在释放之前得到更新。
在我自己的测试中,我倾向于前者是正确的,但这条推文让我怀疑这个事实,也许我不知道 AutoRenewTimeout 的完整用法
你的测试是正确的。
AutoRenewTimeout
将允许延长处理时间超过 LockDuration
w/o 增加 DeliveryCount
。它应该设置为最大处理时间回调。将其读取为等待处理回调完成的时间范围。在那之后 OnMessage API 将不会发出更新。