Lock duration significance on azure service bus topic subscriptions
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.