1

When a Azure Queue triggered function fails, when will the message become available in the queue for retry?

Is it:

  • After the visibility timeout elapses

or

  • Right away on failure

Failure = function throws an Exception.

Janusz Nowak
  • 2,595
  • 1
  • 17
  • 36
marius-O
  • 395
  • 3
  • 15

2 Answers2

0

It will be picked up again immediately. I ran a sample failing queue-triggered function, and it got triggered 5 times within few seconds. After 5 attempts, the item was moved to xyz-poison queue.

Mikhail Shilkov
  • 34,128
  • 3
  • 68
  • 107
  • I don't suppose you've got a link for documentation on the behavior. Was asking because of https://stackoverflow.com/a/40011705/1183475, that's in Oct'16 and they were saying they're going to make them retry right away, I'll also try it myself now ... – marius-O Aug 23 '17 at 16:09
0

I can't find documentation, so maybe ask for it over in this repo https://github.com/Azure/azure-webjobs-sdk

but looking at the code here should answer your question

    /// <summary>
    /// This method completes processing of the specified message, after the job function has been invoked.
    /// </summary>
    /// <remarks>
    /// If the message was processed successfully, the message should be deleted. If message processing failed, the
    /// message should be release back to the queue, or if the maximum dequeue count has been exceeded, the message
    /// should be moved to the poison queue (if poison queue handling is configured for the queue).
    /// </remarks>
    /// <param name="message">The message to complete processing for.</param>
    /// <param name="result">The <see cref="FunctionResult"/> from the job invocation.</param>
    /// <param name="cancellationToken">The <see cref="CancellationToken"/> to use</param>
    /// <returns></returns>
    public virtual async Task CompleteProcessingMessageAsync(CloudQueueMessage message, FunctionResult result, CancellationToken cancellationToken)
    {
        if (result.Succeeded)
        {
            await DeleteMessageAsync(message, cancellationToken);
        }
        else if (_poisonQueue != null)
        {
            if (message.DequeueCount >= MaxDequeueCount)
            {
                // These values may change if the message is inserted into another queue. We'll store them here and make sure
                // the message always has the original values before we pass it to a customer-facing method.
                string id = message.Id;
                string popReceipt = message.PopReceipt;

                await CopyMessageToPoisonQueueAsync(message, _poisonQueue, cancellationToken);

                // TEMP: Re-evaluate these property updates when we update Storage SDK: https://github.com/Azure/azure-webjobs-sdk/issues/1144
                message.UpdateChangedProperties(id, popReceipt);

                await DeleteMessageAsync(message, cancellationToken);
            }
            else
            {
                await ReleaseMessageAsync(message, result, VisibilityTimeout, cancellationToken);
            }
        }
        else
        {
            // For queues without a corresponding poison queue, leave the message invisible when processing
            // fails to prevent a fast infinite loop.
            // Specifically, don't call ReleaseMessage(message)
        }

}

ahmelsayed
  • 7,125
  • 3
  • 28
  • 40