Azure Service Bus keeps throwing MessageLockLostExceptions

后端 未结 2 927
悲&欢浪女
悲&欢浪女 2021-01-14 09:42

I keep getting MessageLockLostExceptions when processing messages.

  • I am using Microsoft.Azure.ServiceBus 3.2.0 with .NET Core 2.1.
  • I hav
2条回答
  •  心在旅途
    2021-01-14 10:20

    You need to Complete the message before the Lock Token gets expired. Once the Lock Token is expired, you will receive MessageLockLostException during the complete operation.

    I can see that you are delaying the thread execution by 10 seconds for each message. But the messages seems to be fetched at the same point of time, that's why the remaining lock duration keeps reducing for each message.

    For the fourth message, the Remaining lock duration is 00:00:00.1776760. So, after 177 milliseconds, the lock will expire. You are delaying the thread by 10 seconds in the next line. So, the lock would expire and you are getting MessageLockLostException. To avoid this exception, remove the Delay

提交回复
热议问题