0

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 Answers1

0

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.

Sean Feldman
  • 23,443
  • 7
  • 55
  • 80
  • my question is how we will determine what will be correct time if my listener function is also depend on some third party api and we are not sure how long it will take ??? then how we can set lock time – Maulik Dave Jul 27 '23 at 05:00
  • Is that an HTTP call you're making and waiting for the response while holding on to the message or something else? Does the 3rd party have an SLA within which you're guaranteed to have a response? – Sean Feldman Jul 28 '23 at 18:25
  • SLA are there but it not always match and this un stability of SLA making lock time harder to configure – Maulik Dave Jul 31 '23 at 06:23
  • In that case, no matter what time you'll set, it always can be violated by a response of a few seconds more. I would suggest building your process to account for an SLA + some buffer and, after that, let the message dead-letter, having a process that handles dead-lettered messages. – Sean Feldman Aug 01 '23 at 06:30
  • fire forget will best option here rather then hold queue – Maulik Dave Aug 04 '23 at 10:41
  • I'm not sure how raising an event will help with locking a message. Perhaps you could clarify? – Sean Feldman Aug 04 '23 at 13:38