[英]Mark Azure Queue BrokeredMessage as Processed successfully?
I receive queue message in worker role, but when I try to mark BrokeredMessage
as complete. 我以worker角色接收队列消息,但是当我尝试将BrokeredMessage
标记为完成时。 I get below error: 我得到以下错误:
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. 锁已过期,或者消息已从队列中删除。
Am I missing something? 我错过了什么吗?
As per Mike Z's comment, set the LockDuration (default is 1, can be up to 5 mins) when you create the queue to prevent timeout. 根据Mike Z的评论,在创建队列以防止超时时设置LockDuration (默认值为1,最长可达5分钟)。
QueueDescription qd = new QueueDescription("MyQueue");
qd.LockDuration = ...
if (!namespaceManager.QueueExists("MyQueue"))
{
namespaceManager.CreateQueue(qd);
}
Also, use RenewLock to prevent it from timing out during a long process: 此外,使用RenewLock防止它在漫长的过程中超时:
receivedMessage.RenewLock()
From here: https://stackoverflow.com/a/15305150/188926 从这里: https : //stackoverflow.com/a/15305150/188926
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.