Azure / azure-service-bus-dotnet

☁️ .NET Standard client library for Azure Service Bus
https://azure.microsoft.com/services/service-bus
Other
235 stars 120 forks source link

IsLockTokenSet is always false #604

Closed ghost closed 6 years ago

ghost commented 6 years ago

i need to monitor locked messages in a subscription queue.

Scenario

for my test, i have one message, and i lock it for 5 minutes by using the rest API via postman. when i browse messages, IsLockTokenSet is set to false

MessageReceiver receiver = new MessageReceiver(connectionString, entityPath);           
while (true)
{
    var message = await receiver.PeekAsync();
    if (message == null)
        break;
    bool isLocked = message.SystemProperties.IsLockTokenSet;
    // isLocked is always false...
}
SeanFeldman commented 6 years ago

From IsLockTokenSet XML documentation (remark section):

A lock token will only be specified if the message was received using ReceiveMode.PeekLock

When you peek a message, you're not really receiving the message from the broker perspective. If anything, I'd argue ReceiveMode should have a third mode, Peek.

ghost commented 6 years ago

So there is no way to know if a message is currently locked ? Informations like LockedUntilUtc, are updated only after the message is unlocked

SeanFeldman commented 6 years ago

So there is no way to know if a message is currently locked (by another competing consumer)?

Correct.

Informations like LockedUntilUtc, are updated only after the message is unlocked

Information such as LockedUntilUtc, IsLockTokenSet, and LockToken are there when a message is received.

SeanFeldman commented 6 years ago

Given this is a question and not an issue with the client, going to close this issue.