skip to Main Content

I’m using Azure Queues to save failed messages.

Each message have to be retried by an Azure Function 10 times before it is discarded.

How can I establish the delay between each retry? (if I use standard behaviour the message is retried 10 times in less than a second)

2

Answers


  1. That’s a normal behavior for Azure Functions with Service Bus. If you need to have a delay between the retries, you’ll need to implement a custom logic that either defers the original message and sends a scheduled message with the deferred original message’s sequence number to retrieve it when the scheduled message appears on the queue and processed by the function. Or, alternatively, use a 3rd party library that supports this feature.

    Login or Signup to reply.
  2. Your question does not make it 100% clear if you are using queues in Azure Storage or Azure Service Bus. If you are using Azure Storage Queues:

    You can leverage visibilityTimeout to configure the time between retries. Internally, this will lock the message to the current consumer for a specified amount of time. In case of error, the message will not be deleted and after the timeout Azure Queue makes the message available again to any available consumers.

    https://learn.microsoft.com/en-us/azure/azure-functions/functions-bindings-storage-queue?tabs=in-process%2Cextensionv5%2Cextensionv3&pivots=programming-language-csharp#host-json

    {
        "version": "2.0",
        "extensions": {
            "queues": {
                "maxPollingInterval": "00:00:02",
                "visibilityTimeout" : "00:00:30",
                "batchSize": 16,
                "maxDequeueCount": 5,
                "newBatchThreshold": 8,
                "messageEncoding": "base64"
            }
        }
    }
    

    visibilityTimeout The time interval between retries when processing of a message fails.

    See also this answer for some more details: Azure function visibilityTimeout

    Login or Signup to reply.
Please signup or login to give your own answer.
Back To Top
Search