Azure Service Bus# PeekLock # determine message lock correct value?

64 Views Asked by At

I have some microservices which post message in queue and then one my listen function listen it and do a further process.

I set Lock time for 120 sec but what is best way to determine and set lock time for queue listener. cos I have 10 replica of same function running at same time and I want to make sure if any function pick that message it must be lock until it complete process.

I put random number now as 120 lock time but what is way to calculate it if we are calling some other api from that listener function cos we are not sure how other api are going to behave.

1

There are 1 best solutions below

6
Sean Feldman On

In Peek Lock mode, lock duration time usually depends on the longest execution possible, which could be up to 5 minutes today with Azure Service Bus. If the operation completes faster than that, the message will be completed, and the next one will be retrieved. The way Azure Functions are implemented, a processor is used that can automatically extend the lock time if processing takes longer. This is achieved by specifying maxAutoRenewDuration in the host.json file. By default, the value is set to 5 minutes. Note that maxAutoRenewDuration should be larger than maxLockDuration.

Regarding Functions App, if it's running in the consumption plan, the maximum execution time will be 10 minutes.