BlobTrigger在Azure WebJobs 0.3 Beta中多次触发作业

编程入门 行业动态 更新时间:2024-10-26 08:28:50
本文介绍了BlobTrigger在Azure WebJobs 0.3 Beta中多次触发作业的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

升级到WebJobs 0.3 beta后,当将Blob发布到存储时,Azure WebJobs多次调用我的方法(以BlobTrigger作为输入).在控制台和Azure中进行本地测试时,都会发生这种情况. 就我而言,我正在使用BlobTrigger,然后将其发布到队列中,如下所示:

After upgrading to WebJobs 0.3 beta, Azure WebJobs is calling my method (with BlobTrigger as input) multiple times when a blob is posted to storage. This happens both when testing locally at the Console, and in Azure. In my case, I am taking the BlobTrigger, and then posting to a queue, like so:

public static void ProcessFactoryFileSubmission( [BlobTrigger(blobs.RESPONSE + "/{requestId}_{factoryId}_{filename}")] ICloudBlob blob, [Table(tables.PACKAGE)] CloudTable table, [Queue(queues.FACTORY_RESPONSE)] out FactoryPackageResponseMessage responseQueue)

该队列收到两条消息,并且在webjobs azure仪表板中确实显示了两次被调用的函数.

The queue is getting two messages, and in the webjobs azure dashboard it does show the function being invoked twice.

这是为什么?

推荐答案

pianomanjh,这是一个已知的限制.触发器和输出的一些组合不能很好地发挥作用.让我解释一下这是如何在内部起作用的,以及为什么这种情况不起作用:

pianomanjh, this is a known limitation. There are a few combinations of triggers and outputs that don't play well. Let me explain how this works internally and why this case doesn't work:

案例1:BlobTrigger(输入)+ Blob(输出):通过查找必须存在且较新的输出blob,很容易知道是否处理了输入blob.

Case 1: BlobTrigger (input) + Blob (output): it is easy to know if the input blob was processed by looking for the output blob, which must exist and be newer.

情况2:QueueTrigger(输入)+任何输出:很容易知道输入是否已处理,因为队列消息在处理后会被删除.

Case 2: QueueTrigger (input) + any output: it is easy to know if the input was processed because the queue message is deleted after it gets processed.

情况3:BlobTrigger(输入)+队列(输出):很难知道输入blob是否已处理,因为队列中的消息可能存在或不存在.另外,我们不会在Blob上存储任何元数据以了解其是否由特定功能处理.

Case 3: BlobTrigger (input) + Queue (output): it is not very easy to know if the input blob was processed because the message in the queue might or might not exist. Also, we are not storing any metadata on the blob to know if it was processed by a particular function.

您遇到的情况是3.一种解决方法是,一旦处理完该blob,就将其移到另一个容器/目录中,这样就不会再次被拾取.

You are hitting case 3. A workaround to this is to move the blob in a different container/directory once it gets processed so it doesn't get picked again.

更多推荐

BlobTrigger在Azure WebJobs 0.3 Beta中多次触发作业

本文发布于:2023-11-24 05:12:51,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1624079.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:作业   Azure   BlobTrigger   WebJobs   Beta

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!