c# – Mark Azure Queue BrokeredMessage已成功处理?

我以worker角色接收队列消息,但是当我尝试将brokeredMessage标记为完成时.我得到以下错误

Client.OnMessage((receivedMessage) =>
    {
        try
        {
            FileContainer fileInfoObj = receivedMessage.GetBody<FileContainer>();               
            //Message processing code               

            receivedMessage.Complete();                           

        }
        catch
        {
            receivedMessage.DeadLetter();
        }
    });

The lock supplied is invalid. Either the lock expired, or the message
has already been removed from the queue.

我错过了什么吗?

解决方法:

根据Mike Z的评论,在创建队列以防止超时时设置LockDuration(认值为1,最长可达5分钟).

QueueDescription qd = new QueueDescription("MyQueue");
qd.LockDuration = ...

if (!namespaceManager.QueueExists("MyQueue"))
{
    namespaceManager.CreateQueue(qd);
}

另外,使用RenewLock防止它在长时间过程中超时:

receivedMessage.RenewLock()

从这里:
https://stackoverflow.com/a/15305150/188926

相关文章

Microsoft云包括了Azure、PowerPlatform、Microsoft365、Git...
《WindowsAzurePlatform系列文章目录》 我们在使用AzureAPI...
微软免费使用一年的Azure虚拟机,默认提供了一个64G的磁盘,...
上篇请访问这里做一个能对标阿里云的前端APM工具(上)样本多...
一年一度的MicrosoftBuild终于来了,带来了非常非常多的新技...