Azure存储队列/功能,仅从毒物队列中退出一次

时间:2018-12-05 18:11:01

标签: azure azure-storage azure-functions azure-storage-queues

我对天蓝色存储功能+天蓝色存储队列有疑问。 我有一个队列-“ myQueue”和队列触发的天蓝色函数“ func1”。在host.json中,我已经配置了maxDequeueCount(5)和visibleTimeout-一切正常。

5次尝试后,我的消息转到“ myQueue-poison”。 我有第二个天蓝色函数“ func2”(从func1复制粘贴),它是从“ myQueue-poison”触发的。我还在host.json中为此功能设置了maxDequeueCount和visibleTimeout。但是此功能仅触发一次-第一次失败运行后,我的消息从队列中消失。 怎么了? 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:\Users\username\source\repos\FunctionApp1\FunctionApp1\bin\Debug\netstandard2.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.

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

1 个答案:

答案 0 :(得分:3)

目前尚不支持这种情况。

如果该队列已经是毒物队列,则不会为该毒物队列创建后续的毒物队列。请参见实现here

由于您的中毒队列没有第二个中毒队列,因此在您的功能仍在运行时不会释放该消息,即可能需要10分钟才能再次看到该消息。请参见实现here