Mandar Jogalekar
Mandar Jogalekar

Reputation: 3281

Lock duration significance on azure service bus topic subscriptions

I have been looking at lockdurations and renewlock mechanisms for service bus queue and topics. However it is not clear about what exactly does lock duration mean for topic subscriptions.

For example:

If i have a topic GameScoreUpdate and it has multiple subscribers.

So any message to this topic will be delivered to all the subscribers.

now if On one subscription "Subscription1", i have a lock duration of 30 seconds. but message processing is not complete.then the lock expires?

What happens after this? the other subscribers have already been delivered this message. current subscriber is processing the message.

Whats the significance of lockduration in this case?

Upvotes: 13

Views: 17186

Answers (1)

Sean Feldman
Sean Feldman

Reputation: 25994

Think of each subscription as an "inbox". Each subscriber gets one. A message is sent to all subscribers, but realistically, it's a clone of the message that is placed into every "inbox", assuming it has a matching criteria.

When a given subscriber tries to process a message from an "inbox" using PeekLock mode, the message is marked as invisible. If there's a failure to process the message in LockDuration time, the message will re-appear in the "inbox" and will be attempted for processing again. Until MaxDeliveryCount attempts are exhausted. In that case, message will be dead-lettered.

This is really needed for competing consumers. I.e. when your subscriber (a process looking at a given subscription/"inbox") is scaled out for processing larger number of messages.

Whats the significance of lockduration in this case?

LockDuration instructs a queue (subscription is a queue after all) to keep message invisible from competing consumers to ensure current processing node can handle it withing time frame defined by LockDuration. Renew lock mechanism ensures that the lock on the currently being processed message is extended to allow longer than LockDuration processing time if needed so. Important thing to remember, lock renewal is not guaranteed to be successful.

Upvotes: 23

Related Questions