0
votes

Currently I am using Azure Service Bus Session Queue by configuring the 30 seconds as a lock duration.

For example, I have one session with 3 messages

  1. While processing the first message to took more time, after that I am calling CompleteAsync() for deleting the message from the queue. But whenever I execute CompleteAsync(), I am getting SessionLockLostException.

    await session.CompleteAsync(message.SystemProperties.LockToken);
    

I want to renew the lock whenever lock has expired.

I followed this documentation, but I am not getting any sample for renew lock token.

1

1 Answers

2
votes

I want to renew the lock whenever lock has expired.

Not possible. Once lock token has expired, the broker will consider it unlocked and serve to other consumers. Instead, you should review your configuration and design approach. If you receive messages that can take longer to process, don't use MaxLockDuration of 30 seconds, up it up. If 5 minutes is not sufficient, look at either extending the lock time manually before it expires, or if using the built-in message pump, configure the maximum time to auto-renew the lock.