我正在使用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 回答
据我所知,目前我们不能将Storage SDK 8.x与WebJobs SDK一起使用,其他人也报告了类似的问题 .
Poison messages stay undeleted-but-invisible with the latest WindowsAzure.Storage 8.1.1
WebJobs V1.1.2 fails to remove poison messages from queue with V8.0.1 of Storage
如果您使用的是Azure Storage SDK 8.x,请尝试降级Azure Storage SDK的版本 . 此外,在第二个链接中,asiffermann与我们分享了一个示例解决方法:编写自定义QueueProcessor以在CopyMessageToPoisonQueueAsync中创建新的CloudQueueMessage,请参阅它 .