1

I follow Microsoft's document to setup (using c#) but message will be expired due to Service Bus queue’s lock duration.

isSessionsEnabled is false, my setting in `host.json is as below for reference:

{
    "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"
            }
        }
    }
}

I also tried to not implement extensions in host.json (as from document it will auto-renew the lock) but still does not work.

For reference, found this mentioned that Microsoft's document may have something wrong but did not mention possible solutions.

DaiKeung
  • 1,077
  • 1
  • 19
  • 38

2 Answers2

1

There is no need to renew the lock manually as its control by the run time of function. Function can renew the message lock by itself.

If you have set isSessionsEnabled to true, the sessionHandlerOptions will honored. As you have set isSessionsEnabled to false, then messageHandlerOptions will honored.

The Peeklock behavior :

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.

Please refer this for further information about Message expiration .

AjayKumarGhose
  • 4,257
  • 2
  • 4
  • 15
0

Can you share the signature of your function? I believe maxAutoRenewDuration only applies for functions receiving a single message, i.e. won't work for functions receiving an array/list of messages.

Josh Love
  • 310
  • 1
  • 5
  • Hi @Josh, here is my signature of function: public async Task Run([ServiceBusTrigger(QueueName, Connection = "ServiceBus")] Message msg, MessageReceiver messageReceiver, ILogger log, ExecutionContext context) { } – DaiKeung Aug 03 '21 at 01:39
  • Ah ok, there goes that theory :( – Josh Love Aug 03 '21 at 02:50