BlobTrigger在Azure WebJobs 0.3 Beta中多次触发作业 [英] BlobTrigger triggering job multiple times in Azure WebJobs 0.3 Beta

查看:68
本文介绍了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中多次触发作业的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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