0
votes

I’m using Azure WebJobs SDK 2.0 and when I specify VisibilityTimeout then MaxDequeuCount, the message is not removed from the queue when it fails 3 times but only copied to poison queue. You can see the DequeueCount is greater than MaxDequeuCount and the message is still in the queue.

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();
        }
    }

The function is throwing an exception to mimic the error condition.

 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");
        }
    }

After three tries the message is moved to the poison queue, which is expected but after 10 minutes or so the message that was moved to poison queue appears again in the queue. console output

In the queue you can see that Dequeue count is greater than MaxDequeuCount and still the message is not deleted from the queue.queue

In the poison queue you can see M1 message processed twice.

1

1 Answers

0
votes

message is not removed from the queue when it fails 3 times but only copied to poison queue

As far as I know, currently we cannot use Storage SDK 8.x with WebJobs SDK, others have reported the similar issue.

If you are using Azure Storage SDK 8.x, please try to downgrad the version of Azure Storage SDK. Besides, in the second link, asiffermann shared us a workaround with sample: write a custom QueueProcessor to create a new CloudQueueMessage in CopyMessageToPoisonQueueAsync, please refer to it.