I keep getting MessageLockLostExceptions
when processing messages.
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