Was Mark Azure Queue BrokeredMessage handled successfully?

I get a queue message as a worker, but when I try to mark it BrokeredMessageas completed. I get below error:

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

            receivedMessage.Complete();                           

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

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

Did I miss something?

+4
source share
1 answer

According to Mike Z's comment, set LockDuration (default is 1, maybe up to 5 minutes) when you create a queue to prevent a timeout.

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

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

In addition, use RenewLock to prevent it from timing during a long process:

receivedMessage.RenewLock()

: fooobar.com/questions/601529/...

+5

All Articles