Azure存储队列/函数,仅从毒药队列出列一次



我在azure存储功能+azure存储队列方面遇到问题。我有一个队列-"myQueue"和队列触发的azure函数"func1"。在host.json中,我配置了maxDequeueCount(5(和visibilityTimeout,一切都很好。

尝试5次后,我的消息转到"myQueue poison"。我有第二个azure函数"func2"(从func1复制粘贴(,它是由"myQueue poison"触发的队列。我还在host.json中为这个函数设置了maxDequeueCount和visibilityTimeout。但这个函数只触发一次——在第一次运行失败后,我的消息从队列中消失。怎么了?host.json和c#代码完全相同,只是队列的名称不同。

以下是功能1和功能2的代码。

[FunctionName("Function1")]
public static void Run([QueueTrigger("myqueue-poison", Connection = "AzureWebJobsStorage")]string myQueueItem, ILogger log)
{
Exception ex = new Exception();
throw ex;
}

[FunctionName("Function2")]
public static void Run([QueueTrigger("myqueue", Connection = "AzureWebJobsStorage")]string myQueueItem, ILogger log)
{
Exception ex = new Exception();            
throw ex;
}

示例日志消息,其中从毒药队列处理的消息存在延迟。

[12/5/2018 9:39:16 PM] Loading functions metadata
[12/5/2018 9:39:16 PM] 2 functions loaded
[12/5/2018 9:39:17 PM] Generating 2 job function(s)
[12/5/2018 9:39:17 PM] Found the following functions:
[12/5/2018 9:39:17 PM] FunctionApp1.Function1.Run
[12/5/2018 9:39:17 PM] FunctionApp1.Function2.Run
[12/5/2018 9:39:17 PM]
[12/5/2018 9:39:17 PM] Host initialized (662ms)
[12/5/2018 9:39:17 PM] Host started (707ms)
[12/5/2018 9:39:17 PM] Job host started
Hosting environment: Production
Content root path: C:UsersusernamesourcereposFunctionApp1FunctionApp1binDebugnetstandard2.0
Now listening on: http://0.0.0.0:7071
Application started. Press Ctrl+C to shut down.
[12/5/2018 9:39:18 PM] Executing 'Function2' (Reason='New queue message detected on 'myqueue'.', Id=20bf83c5-3142-4092-9d85-7a2a6fbcf863)
[12/5/2018 9:39:18 PM] Executed 'Function2' (Failed, Id=20bf83c5-3142-4092-9d85-7a2a6fbcf863)
[12/5/2018 9:39:18 PM] System.Private.CoreLib: Exception while executing function: Function2. FunctionApp1: Exception of type 'System.Exception' was thrown.
[12/5/2018 9:39:18 PM] Executing 'Function2' (Reason='New queue message detected on 'myqueue'.', Id=49775db2-0c91-41cb-b472-a3aceee1bac3)
[12/5/2018 9:39:19 PM] Executed 'Function2' (Failed, Id=49775db2-0c91-41cb-b472-a3aceee1bac3)
[12/5/2018 9:39:19 PM] System.Private.CoreLib: Exception while executing function: Function2. FunctionApp1: Exception of type 'System.Exception' was thrown.
[12/5/2018 9:39:19 PM] Executing 'Function2' (Reason='New queue message detected on 'myqueue'.', Id=0a1d103a-41a0-4630-a479-c72297a368b8)
[12/5/2018 9:39:19 PM] Executed 'Function2' (Failed, Id=0a1d103a-41a0-4630-a479-c72297a368b8)
[12/5/2018 9:39:19 PM] System.Private.CoreLib: Exception while executing function: Function2. FunctionApp1: Exception of type 'System.Exception' was thrown.
[12/5/2018 9:39:19 PM] Executing 'Function2' (Reason='New queue message detected on 'myqueue'.', Id=6b79aad1-1eb6-4cfe-b39c-a7078f006968)
[12/5/2018 9:39:20 PM] Executed 'Function2' (Failed, Id=6b79aad1-1eb6-4cfe-b39c-a7078f006968)
[12/5/2018 9:39:20 PM] System.Private.CoreLib: Exception while executing function: Function2. FunctionApp1: Exception of type 'System.Exception' was thrown.
[12/5/2018 9:39:20 PM] Executing 'Function2' (Reason='New queue message detected on 'myqueue'.', Id=cf401aee-133d-42ac-a8e0-25fe95ebe162)
[12/5/2018 9:39:20 PM] Executed 'Function2' (Failed, Id=cf401aee-133d-42ac-a8e0-25fe95ebe162)
[12/5/2018 9:39:20 PM] System.Private.CoreLib: Exception while executing function: Function2. FunctionApp1: Exception of type 'System.Exception' was thrown.
[12/5/2018 9:39:20 PM] Message has reached MaxDequeueCount of 5. Moving message to queue 'myqueue-poison'.
[12/5/2018 9:39:20 PM] Executing 'Function1' (Reason='New queue message detected on 'myqueue-poison'.', Id=2b1bd5ec-67e2-41c9-bd7b-6a3fde48cd04)
[12/5/2018 9:39:21 PM] Executed 'Function1' (Failed, Id=2b1bd5ec-67e2-41c9-bd7b-6a3fde48cd04)
[12/5/2018 9:39:21 PM] System.Private.CoreLib: Exception while executing function: Function1. FunctionApp1: Exception of type 'System.Exception' was thrown.
[12/5/2018 9:39:22 PM] Host lock lease acquired by instance ID '0000000000000000000000004EE22C73'.
[12/5/2018 9:49:20 PM] Executing 'Function1' (Reason='New queue message detected on 'myqueue-poison'.', Id=83f83d31-44e6-46cf-a235-08360e5adc60)
[12/5/2018 9:49:21 PM] Executed 'Function1' (Failed, Id=83f83d31-44e6-46cf-a235-08360e5adc60)
[12/5/2018 9:49:21 PM] System.Private.CoreLib: Exception while executing function: Function1. FunctionApp1: Exception of type 'System.Exception' was thrown.
[12/5/2018 9:59:21 PM] Executing 'Function1' (Reason='New queue message detected on 'myqueue-poison'.', Id=54acbb91-d4db-4737-ae90-47b17df5998c)
[12/5/2018 9:59:21 PM] Executed 'Function1' (Failed, Id=54acbb91-d4db-4737-ae90-47b17df5998c)
[12/5/2018 9:59:21 PM] System.Private.CoreLib: Exception while executing function: Function1. FunctionApp1: Exception of type 'System.Exception' was thrown.

因此,看起来来自毒药队列的消息的读取方式与正常队列不同。是否有任何配置可以用于减少毒品队列处理的延迟?

目前不支持这种情况。

如果队列已经是毒药队列,则不会为毒药队列创建后续的毒药队列。请在此处查看实施情况。

由于您的毒药队列没有第二个毒药队列,因此当您的功能仍在运行时,消息不会被释放,即您可能需要10分钟才能再次看到消息。请在此处查看实施情况。

最新更新