Azure 队列触发函数错误

标签 azure azure-functions azure-queues

当 Azure 队列触发函数失败时,消息何时会在队列中可供重试?

是吗:

  • 可见性超时后

  • 失败时立即

失败=函数抛出异常

最佳答案

我找不到文档,所以也许可以在此存储库中索取它 https://github.com/Azure/azure-webjobs-sdk

但看看代码here应该回答你的问题

    /// <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)
        }

}

关于Azure 队列触发函数错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45835402/

相关文章:

azure - MS Azure Webrole - 如何指定 Web 根驱动器存储大小

azure - Azure Functions v2 中的 WebJobsStartup 在定位 netcoreapp2.1 时不起作用

azure - Azure 队列中的列由什么决定?

Azure 存储资源管理器 - 未显示 "failed"队列项目?

azure - 使用 Azure 总线服务时,ServiceBus/ServiceBusTrigger 方法与使用 QueueClient 的方法有什么区别?

json - 将json配置文件添加到Azure功能以进行本地开发

Azure 开发运营 : How to export the Work Items from an Azure DevOps Project using REST APIs?

azure - 如何读取Azure存储 key

c# - 如果同时运行多个项目,Azurite 存储模拟器将停止

azure - 在 azure 功能中,是否可以使用应用程序设置作为绑定(bind)路径的一部分?