MessageLockLostException inspite of setting a AutoRenew on messagereceivers

1,167 views
Skip to first unread message

Haripraghash Subramaniam

unread,
Dec 27, 2016, 8:37:58 AM12/27/16
to Particular Software
Helpful information to include
Product name: Nservice.core and ASB transport
Version: 6.1.1 and 7.1.0
Stacktrace:
Description: Microsoft.ServiceBus.Messaging.MessageLockLostException: The lock supplied is invalid. Either the lock expired, or the message has already been removed from the queue. TrackingId:9a26a57d-47ff-4d7b-bd12-3f0c9dfb150f_G30_B15,

I have an Azure worker role which hosts a NServicebus endpoint. I have set a AutoRenewTimeOut on MessageReqceivers to be about 10 mins. The LockDuration for the message is 60 seconds. Inspite of this i get a Warning message saying MessagLock has been lost.

Sean Feldman

unread,
Dec 28, 2016, 2:06:42 AM12/28/16
to Particular Software
I've ran a quick test with the following config:

transport.MessageReceivers()
 
.AutoRenewTimeout(TimeSpan.FromMinutes(10));

and a handler code to mimic 6 minutes processing (exceeds max 5 minutes locking):

public async Task Handle(Message message, IMessageHandlerContext context)
{
 
Trace.WriteLine($"--- processing started {DateTime.Now}");
 
await Task.Delay(TimeSpan.FromMinutes(6));
 
Trace.WriteLine($"--- processing ended {DateTime.Now}");
}

Code worked as expected:

--- processing started 2016-12-27 23:58:50
--- processing ended 2016-12-28 00:04:50

If you could share a reproduction code to demo a case where it wouldn't work, it would help. 
Thank you.

Sean Feldman

unread,
Dec 28, 2016, 2:15:57 AM12/28/16
to Particular Software
This kind of warning would indicate that the message re-appeared on the queue and no longer locked by the process that got it initially.
Do you see the message on the queue? And if you do, what's the DeliveryCount on it?

Sean Feldman

unread,
Jan 3, 2017, 9:57:49 AM1/3/17
to Particular Software
Hi Haripraghash,
Have you had a chance to try to repro this? I couldn't get the same result as you did.
Reply all
Reply to author
Forward
0 new messages