Azure功能可见性超时

编程入门 行业动态 更新时间:2024-10-25 08:19:01
本文介绍了Azure功能可见性超时的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

当我阅读有关能见度超时的文档时: docs.microsoft/zh-cn/azure/azure-functions/functions-bindings-storage-queue#host-json 它说:处理消息失败.".我的理解是,如果超时设置为30秒,并且我的函数运行了1分钟,但在那1分钟内没有失败,则该消息对队列中的其他人不可见.但是,当我通过其他来源(stackoverflow fx)对其进行阅读时,它告诉我相反的情况,即当函数的执行时间超过超时时,即使该函数仍在处理该消息,该消息也变得可见.

When i read the documentation about visibilityTimeout: docs.microsoft/en-us/azure/azure-functions/functions-bindings-storage-queue#host-json it says "The time interval between retries when processing of a message fails.". How I understands this is that if the timeout is set to 30 seconds and my function runs for 1 minute but doesn't fail in that 1 minute period, the message doesn't get visible to others in the queue. But when I read up on it by others sources (stackoverflow fx) it tells me the opposite, that when the execution time of the function exceeds the timeout, the message becomes visible EVEN though the function is still processing the message.

真相是什么?仅在功能未运行更多(可能已经失败)时才相关的超时,还是即使功能仍在运行,消息是否又可以再次显示?

What is the truth? Is the timeout only relevant when the function isn't running more (and maybe have failed) or can it happen that the message gets visible again even though the function is still running?

如果我们假设消息在达到超时时可见,那么没有意义的是默认超时为00:00:00,这意味着消息在出队的同时可见.这与3.政党消息人士的说法相矛盾.

What doesn't makes sense either, if we assume that the message gets visible when timeout is reached, is that the default timeout is 00:00:00 which implies that the message is visible at the same moment it is dequeued. This contradicts what 3. party sources is saying.

对此我有点困惑.

推荐答案

我已经用

using System; using System.Threading; using System.Threading.Tasks; using Microsoft.Azure.WebJobs; using Microsoft.Azure.WebJobs.Host; using Microsoft.Extensions.Logging; using Microsoft.WindowsAzure.Storage.Queue; namespace WorkerFunctions { public static class WorkerFunctions { [FunctionName("WorkerFunction1")] public static async Task Function1( [QueueTrigger("outputQueue")] CloudQueueMessage item, [Queue("outputQueue")] CloudQueue outputQueue, DateTimeOffset nextVisibleTime, DateTimeOffset expirationTime, DateTimeOffset insertionTime, ILogger log) { log.LogInformation("########## Function 1 ###############"); log.LogInformation($"NextVisibleTime: {nextVisibleTime}"); log.LogInformation($"NextVisibleTime: {(nextVisibleTime-insertionTime).TotalSeconds}"); log.LogInformation($"C# Queue trigger function processed: {item.AsString}"); Thread.Sleep(TimeSpan.FromMinutes(20)); } [FunctionName("WorkerFunction2")] public static async Task Function2( [QueueTrigger("outputQueue")] CloudQueueMessage item, [Queue("outputQueue")] CloudQueue outputQueue, DateTimeOffset nextVisibleTime, DateTimeOffset expirationTime, DateTimeOffset insertionTime, ILogger log) { log.LogInformation("########## Function 2 ###############"); log.LogInformation($"NextVisibleTime: {nextVisibleTime}"); log.LogInformation($"NextVisibleTime: {(nextVisibleTime - insertionTime).TotalSeconds}"); log.LogInformation($"C# Queue trigger function processed: {item.AsString}"); Thread.Sleep(TimeSpan.FromMinutes(20)); } } }

使用此主机文件

{ "version": "2.0", "extensions": { "queues": { "maxPollingInterval": "00:00:02", "visibilityTimeout": "00:00:10", "batchSize": 16, "maxDequeueCount": 5, "newBatchThreshold": 8 } } }

当我在队列中放入一条简单的消息并使其运行时,我看到以下内容:

And when i put a simple message on the queue and let it run, I see the following:

  • 捕获它的功能,不会在睡眠结束之前释放它
  • 我在续订的日志中看不到它,但是好像发生在幕后
  • 这告诉我:

  • 如果功能没有失败,或者主机没有失败,那么租约将根据以下内容自动续订: stackoverflow/a/31883806/21199
  • 达到可见性超时并且功能正在运行时,消息不会重新添加"到队列中
  • 有关visibilityTimeout的文档为true:消息处理失败时重试之间的时间间隔. (来自 docs.microsoft/zh-CN/azure/azure-functions/functions-bindings-storage-queue#hostjson-settings )
  • if the function doesn't fail, OR the host doesn't fail, well then the lease is autorenewed according to: stackoverflow/a/31883806/21199
  • when the visibility timeout is reached, and the function is running, the message doesn't get "readded" to the queue
  • that the documentation about the visibilityTimeout is true: "The time interval between retries when processing of a message fails." (from docs.microsoft/en-us/azure/azure-functions/functions-bindings-storage-queue#hostjson-settings)
  • 我没有保存任何指向与此方相反的链接.3.抱歉,我没有保存这些链接,但是它们存在.希望有人会回答这个问题,以便我澄清.

    I haven't saved any links to 3. party that contradicted this (sorry I haven't saved these), but they exists. I wish someone will answer this, so I can get clarification.

    更多推荐

    Azure功能可见性超时

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

    发布评论

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

    >www.elefans.com

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