How to delay the execution of an Azure function after its failure?

I use the Azure function (written in C #), which runs when a new message appears in the storage queue. This function calls an external web service to process the message, and when the external service responds, everything is in order.

The problem is that the external website is disabled and the web client throws an exception (without a try / catch block). Then what happens is that the function is executed repeatedly (by blue) 5 times, in less than a second between each attempt. As you can imagine, the web service will probably still be unavailable for all 5 attempts that will cause the azure to move the message to the "poison" circle.

Is it possible to set the timeout before retrying, or do I need to set up another azure function that runs once a minute to check the poison queue for messages, which then need to be recreated in normal mode?

+4
source share
3 answers

We do not currently provide you with a way to set the visibility timeout for failed messages. He is currently tightly attached to TimeSpan.Zero, as you noticed. I agree with you that we must enable this setting. I registered a problem in our public repo with more details here .

+4
source

- , , .

.

Function is triggered
        \  /
         \/
Do we have a message in service-status queue?
        \  /
         \/    
Wait 30 seconds before making web-service call / else call it right away.
        \  /
         \/
Can't reach web-service? -> Drop message in service-status queue.

-, , .

0

visibilityTimeout "": , SDK Azure.

. https://github.com/teamdigitale/digital-citizenship-functions/blob/master/lib/utils/azure_queues.ts#L86

 queueService.updateMessage(
        queueName,
        queueMessage.id,
        queueMessage.popReceipt,
        visibilityTimeoutSec,
        err => {
          context.done( err );
        }
      );

This will enable the exponential deferral strategy for retries without putting the process to sleep.

0
source

Source: https://habr.com/ru/post/1655540/


All Articles