Azure存储队列和多个WebJobs实例:QueueTrigger会在触发时设置消息租用时间吗? [英] Azure Storage Queue and multiple WebJobs instances: will QueueTrigger set the message lease time on triggered?

查看:200
本文介绍了Azure存储队列和多个WebJobs实例:QueueTrigger会在触发时设置消息租用时间吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

场景:生产者将一条消息发送到存储队列中,一个WebJobs在QueueTrigger上处理该消息,每条消息只能被处理一次,可能有多个WebJob实例.

Scenario: producer send a message into the Storage Queue, a WebJobs process the message on QueueTrigger, each message must only be processed once, there could be multiple WebJob instances.

我一直在使用Google搜索,从阅读的内容来看,我需要编写将消息处理为幂等的函数,这样就不会对消息进行两次处理.我还读到一条消息的默认租用时间为10分钟.

I've been googling and from what I've read, I need to write the function that processes the message to be idempotent so a message isn't processed twice. I've also read that there is a default lease time of 10 minutes for a message.

我的问题是,当在一个WebJob实例上触发QueueTrigger时,它是否设置了消息的租用时间,以使另一个WebJob无法接收相同的消息?如果是这样,为什么我需要考虑该消息可以被处理两次的可能性?还是我误会了?

My question is, when the QueueTrigger is triggered on one WebJob instance, does it set the lease time on the message so that another WebJob can't pick up the same message? If so why do I need to account for the possibility that the message can be processed twice? Or am I misunderstanding this?

推荐答案

如果您使用内置的队列触发器属性,即使站点扩展到多个实例,它也将自动确保任何给定消息都会被处理一次. .这发布在讨论部分的文章中,

If you are using the built-in queue trigger attributes, it will automatically ensure that any given message gets processed once, even when a site scales out to multiple instances. This is posted on the article in the discussion section, https://azure.microsoft.com/en-us/documentation/articles/websites-dotnet-webjobs-sdk-get-started/

在同一篇文章中,您会发现有关10分钟租约的说明.总之,当队列中收到新消息时,QueueTrigger属性指示WebJobs SDK调用方法.消息已处理,方法完成后,队列消息将被删除.如果该方法在完成之前失败,则不会删除队列消息; 10分钟的租约到期后,将释放该消息以再次提取并处理该消息.如果消息总是导致异常,则不会无限期重复此序列.在尝试处理一条消息5次失败后,该消息将移至中毒队列.最大尝试次数是可配置的.

In the same article you will find clarification regarding the 10 minute lease. In summary, the QueueTrigger attribute directs the WebJobs SDK to call a method when a new message is received in queue. The message is processed and when the method completes, the queue message is deleted. If the method fails before completing, the queue message is not deleted; after a 10-minute lease expires, the message is released to be picked up again and processed. This sequence won't be repeated indefinitely if a message always causes an exception. After 5 unsuccessful attempts to process a message, the message is moved to the poison queue. The maximum number of attempts is configurable.

这篇关于Azure存储队列和多个WebJobs实例:QueueTrigger会在触发时设置消息租用时间吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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