如何从 Azure Functions 更新服务总线消息?
How to renew Service Bus message from Azure Function?
我按照 Microsoft's document 进行设置(使用 c#),但由于服务总线队列的锁定持续时间,消息将过期。
isSessionsEnabled
是false,我在`host.json中的设置如下供参考:
{
"version": "2.0",
"functionTimeout": "00:10:00",
"extensions": {
"serviceBus": {
"prefetchCount": 100,
"messageHandlerOptions": {
"autoComplete": true,
"maxConcurrentCalls": 32,
// tried "00:00:55", "00:02:30", "00:05:00"
"maxAutoRenewDuration": "00:10:00"
}
}
}
}
我也尝试不在 host.json
中实现 extensions
(根据文档,它将自动更新锁)但仍然不起作用。
作为参考,发现提到微软的文档可能有问题,但没有提到可能的解决方案。
你能分享你的函数签名吗?我相信 maxAutoRenewDuration 仅适用于接收单个消息的功能,即不适用于接收 array/list 条消息的功能。
无需手动续锁,由运行功能时间控制。
函数可以自行更新消息锁
如果您已将 isSessionsEnabled
设置为 true
,则 sessionHandlerOptions
将生效。由于您已将 isSessionsEnabled
设置为 false
,因此 messageHandlerOptions
将兑现。
When Functions runtime receieve a message in peek-lock mode
it will call Complete
on the message once the function finishes
successfully, or calls Abandon
if the function fails. If the
function runs longer than the PeekLock
timeout, the lock is
automatically renewed as long as the function is running.
The maxAutoRenewDuration
is configurable in host.json, which
maps to OnMessageOptions.MaxAutoRenewDuration
Based on the documentation maximum allowed time is 5 minute
whereas you can increase the Functions run time
limit from the default of 5 minutes to 10 minutes. For Service Bus
functions you wouldn’t want to do that, because you’d exceed the
Service Bus renewal limit.
有关 Message expiration 的更多信息,请参阅此处。
我按照 Microsoft's document 进行设置(使用 c#),但由于服务总线队列的锁定持续时间,消息将过期。
isSessionsEnabled
是false,我在`host.json中的设置如下供参考:
{
"version": "2.0",
"functionTimeout": "00:10:00",
"extensions": {
"serviceBus": {
"prefetchCount": 100,
"messageHandlerOptions": {
"autoComplete": true,
"maxConcurrentCalls": 32,
// tried "00:00:55", "00:02:30", "00:05:00"
"maxAutoRenewDuration": "00:10:00"
}
}
}
}
我也尝试不在 host.json
中实现 extensions
(根据文档,它将自动更新锁)但仍然不起作用。
作为参考,发现
你能分享你的函数签名吗?我相信 maxAutoRenewDuration 仅适用于接收单个消息的功能,即不适用于接收 array/list 条消息的功能。
无需手动续锁,由运行功能时间控制。 函数可以自行更新消息锁
如果您已将 isSessionsEnabled
设置为 true
,则 sessionHandlerOptions
将生效。由于您已将 isSessionsEnabled
设置为 false
,因此 messageHandlerOptions
将兑现。
When Functions runtime receieve a message in peek-lock mode it will call
Complete
on the message once the function finishes successfully, or callsAbandon
if the function fails. If the function runs longer than thePeekLock
timeout, the lock is automatically renewed as long as the function is running.The
maxAutoRenewDuration
is configurable in host.json, which maps toOnMessageOptions.MaxAutoRenewDuration
Based on the documentation maximum allowed time is 5 minute whereas you can increase the Functions run time limit from the default of 5 minutes to 10 minutes. For Service Bus functions you wouldn’t want to do that, because you’d exceed the Service Bus renewal limit.
有关 Message expiration 的更多信息,请参阅此处。