Difference between Lease-Based and Lock-Based exclusive access in Azure Queues
Asked Answered
L

3

17

I know (reading the msdn documentation here) that Windows Azure Storage Queues use a lease-based exclusive access strategy to the messages and Azure Service Bus Queues use a lock-based one. In both I can set the maximum duration of lock/lease. So, which are the most important differences between these two methods? Could someone provide a clear/short example? Thanks.

Labaw answered 21/1, 2015 at 18:15 Comment(0)
P
4

In both cases when you read a message, the message is locked (or leased) and others cannot access it. Difference is, for Storage Queue you can define the lease duration for the message itself (by default is 30 seconds, it can be up to 7 days) so you as the client (publisher) can specify this when pushing the message to the queue; whereas for Service Bus the lock duration is defined at the queue or topic level (default is also 30 seconds), so you as a client (publisher) cannot control this.

Promising answered 23/5, 2022 at 2:50 Comment(0)
M
0

My understanding is that lease-based has a time limit, but lock-based does not have.

For example, the duration of a lease can be 30s long, before current user releases it or the duration expires, others cannot get the lease to access the resource. But after 30s, anyone can get it and access the resource. (Of course, you can set the duration to be infinite.)

For lock-based, if the current user does not release the lock, no one can get the lock.

Medullary answered 24/6, 2015 at 18:26 Comment(1)
Thanks @Medullary for your response, but I think it is not true. Service Bus Queues use a lock-based mechanism, and also have a lock timeout period, (by default 60 seconds).Labaw
G
0

Managing Concurrency in Windows Azure with Leases

@nop's answer is correct.

Leases have auto-timeout feature, so in case if a service which is holding a resource dies, the resource is freed after the set-timeout and the scenario of deadlock is avoided. They also have renew capability.

Graig answered 9/7, 2018 at 6:2 Comment(1)
nop's answer is not correct--they both have timeouts; outlookrperson's comment on nop's answer is correctFoucquet

© 2022 - 2024 — McMap. All rights reserved.