c# - Azure 服务总线自动更新超时

标签 c# azure azureservicebus

我通过 .net SDK 使用 Azure ServiceBus 队列。 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 次,然后放弃并再次在队列中可见。还有其他 StackOverflow 答案也证实了这一点,例如https://stackoverflow.com/a/36051408

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 之外,而无需增加 DeliveryCount。应将其设置为回调的最大处理时间。将其读取为等待处理回调完成的时间范围。此后 OnMessage API 将不会发出更新。

关于c# - Azure 服务总线自动更新超时,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36561227/

相关文章:

asp.net - NGINX HTTPS 代理无法使用 Azure AD 重定向 Uri

c# - 查看没有事件消息的 session 启用主题/订阅时出现超时异常

azureservicebus - 使用 ACS 创建 Azure 服务总线(用于 PHP 集成)

azure - 是否可以在 ServiceBus 死信队列消息上设置 TTL?

c# - 带有隐藏输入的 HttpWebRequest 登录

c# - C# 中的属性名称和方法名称可以相同吗?

没有 web.config 的 Azure 和 .json mimeType

azure - 配置 Azure Pipeline 以从 Github 托管存储库中提取

c# - 正则表达式适用于 .NET 测试站点,但不适用于 C# 环境

c# - 如何摆脱 "API restriction UnitTestFramework.dll already loaded"错误?