简体   繁体   English

多次执行Azure功能队列触发器

[英]Azure Function Queue Trigger Executing Multiple Times

I have azure function triggered off of a storage queue. 我的存储队列触发了azure函数。 The behavior of the function is to create out around 10,000 additional messages to another storage queue for another function (within the same function app) to execute. 该功能的行为是向另一个存储队列中创建大约10,000条附加消息,以供另一个功能(在同一功能应用程序内)执行。 I'm seeing some strange behavior whenever it executes, where the first function appears to be executed multiple times. 每当执行时,我都会看到一些奇怪的行为,第一个函数似乎要执行多次。 I observed this by watching the queue it's publishing to receive significantly more messages than expected. 我通过观察它正在发布的队列接收到的消息明显多于预期来观察到这一点。

I understand that the function should be coded defensively (ie expect to be executed multiple times), but this is happening consistently each time the first function executes. 我知道该功能应进行防御性编码(即希望执行多次),但这在每次执行第一个功能时都会一致发生。 I don't think the repeated executions re due to it timing out or failing (according to app insights). 我不认为重复执行是由于超时或失败(根据应用程序见解)造成的。

Could it be that when the 10,000 messages get queued up the function is scaling out and that is somehow causing the original message to be executed multiple times? 可能是当10,000条消息排队时,该功能正在向外扩展,并且某种程度上导致原始消息被执行了多次?

The lock on the original message that triggers the first Azure Function to execute is likely expiring. 触发第一个Azure功能执行的原始消息上的锁定可能即将到期。 This will cause the Queue to assume that processing the message failed, and it will then use that message to trigger the Function to execute again. 这将导致队列假定处理消息失败,然后它将使用该消息触发功能再次执行。 You'll want to look into renewing the message lock while you're sending out 10,000 messages to the next Queue. 在向下一个队列发送10,000条消息时,您需要研究更新消息锁。

Also, since you're sending out 10,000 messages, you may need to redesign that to be more efficient at scaling out what ever massively parallel processing you're attempting to implement. 另外,由于要发送10,000条消息,因此您可能需要重新设计该消息,以更有效地扩展您尝试实现的大规模并行处理。 10,000 is a really high amount of messages to send from a single triggered event. 10,000是从单个触发事件发送的大量消息。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM