Azure WebJobs:VisibilityTimeout&;MaxDequeuCount不能一起工作

Azure WebJobs:VisibilityTimeout&;MaxDequeuCount不能一起工作,azure,azure-webjobs,Azure,Azure Webjobs,我使用的是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 ru

我使用的是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分钟后,移动到毒药队列的消息将再次出现在队列中。

在队列中,您可以看到Dequeue count大于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();
        }
    }
在毒药队列中,您可以看到M1消息被处理了两次

当消息失败3次时,它不会从队列中删除,而只是复制到队列中

据我所知,目前我们无法将Storage SDK 8.x与WebJobs SDK一起使用,其他人也报告了类似的问题

如果您使用的是Azure Storage SDK 8.x,请尝试降级Azure Storage SDK的版本。此外,在第二个链接中,asiffermann与我们分享了一个样例解决方案:编写一个自定义QueueProcessor以在CopyMessageTopoIsQueueAsync中创建一个新的CloudQueueMessage,请参考它