当我阅读有关能见度超时的文档时: 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:
这告诉我:
我没有保存任何指向与此方相反的链接.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功能可见性超时
发布评论