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)
CodePudding user response:
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.
CodePudding user response:
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.
{
"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