Azure功能和存储队列,如果功能失败该怎么办 [英] Azure Function and storage queue, what to do if function fails

查看:78
本文介绍了Azure功能和存储队列,如果功能失败该怎么办的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在研究一种将消息发布到Azure存储队列的方案.出于测试目的,我开发了一个控制台应用程序,可以在其中获取消息,并能够通过尝试计数对其进行更新,并在逻辑完成后删除消息.

I'm working out a scenario where a post a message to an Azure Storage Queue. For testing purposes I've developed a console app, where I get the message and I'm able to update it with a try count, and when the logic is done, I delete the message.

现在,我正在尝试将代码移植到Azure函数.似乎有很大不同的一件事是,当调用Azure函数时,该消息将从队列中删除.

Now I'm trying to port my code to an Azure Function. One thing that seems to be very different is, when the Azure Function is called, the message is deleted from the queue.

我发现很难找到有关此特定主题的任何文档,而且我觉得在将两者结合起来的概念方面缺少一些东西.

I find it hard to find any documentation on this specific subject and I feel I'm missing something with regard to the concept of combining these two.

我的问题:

  1. 是的,当您在新队列项目上触发函数时,即使函数失败,该函数也会接收消息并将其从队列中删除?
  2. 如果1是正确的,您如何确保重试邮件并将其张贴到无效队列以供以后处理?

推荐答案

仅当函数成功处理队列消息时(即未发生错误),运行时才会删除队列消息.消息出队并传递给您的函数后,它会在一段时间(10分钟)内不可见.当您的函数运行时,这种隐身性得以维持.如果您的函数失败,则该消息未删除-它以不可见状态保留在队列中.可见性超时到期后,该消息将再次在队列中可见以进行重新处理.

The runtime only deletes the queue message when your Function successfully processes it (i.e. no error has occurred). When the message is dequeued and passed to your function, it becomes invisible for a period of time (10 minutes). While your function is running this invisibility is maintained. If your function fails, the message is not deleted - it remains in the queue in an invisible state. After the visibilty timeout expires, the message will become visible in the queue again for reprocessing.

有关核心WebJobs SDK队列处理工作方式的详细信息,请参见部分,该部分解决了您的问题.基本上,您将免费获得所有正确的行为-重试处理,有害消息处理等:)

The details of how core WebJobs SDK queue processing works can be found here. On that page, see the section "How to handle poison messages" which addresses your question. Basically you'll get all the right behaviors for free - retry handling, poison message handling, etc. :)

这篇关于Azure功能和存储队列,如果功能失败该怎么办的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆