Azure Service Bus keeps throwing MessageLockLostExceptions

后端 未结 2 925
悲&欢浪女
悲&欢浪女 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:12

    One thing that is missing from your repro is the queue description. It's important to note such details as the problem you're experiencing has nothing to do with the client and is most likely either related to the broker or the underlying AMQP library.

    For non-partitioned queues this setup works fine. It doesn't for partitioned queues (Standard tier). Can be observed with both the old and the new clients. I've raised a broker related issue for Azure Service Bus team to investigate.

    0 讨论(0)
  • 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

    0 讨论(0)
提交回复
热议问题