简体   繁体   English

将Azure Azure Queue BrokeredMessage标记为已成功处理?

[英]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.

相关问题 在Azure函数中使用BrokeredMessage和ServiceBus队列触发器 - Using BrokeredMessage with ServiceBus Queue Trigger in Azure Function 使用Azure Service Bus Queue和BrokeredMessage.ScheduledEnqueueTimeUtc续订订阅 - using an Azure Service Bus Queue and BrokeredMessage.ScheduledEnqueueTimeUtc to renew subscriptions Azure服务总线队列-当消息在队列中时,QueueClient.Receive()返回空的BrokeredMessage - Azure Service Bus Queue - QueueClient.Receive() returning null BrokeredMessage when messages are in the queue 使用 BrokeredMessage 从 Azure 服务总线队列 (v1) 反序列化强类型对象 - Deserialize strongly typed object from Azure Service Bus Queue (v1) using BrokeredMessage Azure服务总线BrokeredMessage的序列化 - Serialization of Azure Service Bus BrokeredMessage (Azure)BrokeredMessage.GetBody <xxx> - (Azure) BrokeredMessage.GetBody<xxx> 将 BrokeredMessage 从 Postman 发送到 Azure Function - Send BrokeredMessage from Postman to Azure Function 与天蓝色的经纪人消息不知道类型的身体 - with azure brokeredmessage get the body without knowing the type Azure Service Bus中BrokeredMessage主体的编码 - Encoding of BrokeredMessage Body in Azure Service Bus Azure 服务总线:从对象创建 BrokeredMessage - Azure Service Bus: Creating a BrokeredMessage from Object
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM