首页 文章

Azure WebJobs:VisibilityTimeout和MaxDequeuCount无法一起使用

提问于
浏览
0

我正在使用Azure WebJobs SDK 2.0,当我指定VisibilityTimeout然后指定MaxDequeuCount时,如果消息失败3次但仅复制到毒性队列,则不会从队列中删除该消息 . 您可以看到DequeueCount大于MaxDequeuCount,并且消息仍在队列中 .

class Program
    {
        // Please set the following connection strings in app.config for this WebJob to run:
        // AzureWebJobsDashboard and AzureWebJobsStorage
        static void Main()
        {
            var config = new JobHostConfiguration();

            if (config.IsDevelopment)
            {
                config.UseDevelopmentSettings();
            }

            config.Queues.BatchSize = 8;
            config.Queues.MaxDequeueCount = 3;
            config.Queues.VisibilityTimeout = TimeSpan.FromSeconds(5);
            config.Queues.MaxPollingInterval = TimeSpan.FromSeconds(3);


            var host = new JobHost(config);
            // The following code ensures that the WebJob will be running continuously
            host.RunAndBlock();
        }
    }

该函数抛出一个异常来模仿错误条件 .

public class Functions
    {
        // This function will get triggered/executed when a new message is written 
        // on an Azure Queue called queue.
        public static void ProcessQueueMessage([QueueTrigger("queue")] string message, TextWriter log)
        {
            log.WriteLine(message);
            throw new Exception("There was an error processing the message");
        }
    }

在三次尝试之后,消息被移动到毒性队列,这是预期的,但是在大约10分钟之后,移动到毒性队列的消息再次出现在队列中 . console output

在队列中,您可以看到Dequeue计数大于MaxDequeuCount,但仍未从队列中删除消息 . queue

在毒药队列中,您可以看到M1消息处理两次 .

1 回答

相关问题