davsclaus commented on code in PR #27986:
URL: https://github.com/apache/camel/pull/27986#discussion_r4301785982


##########
components/camel-azure/camel-azure-servicebus/src/main/java/org/apache/camel/component/azure/servicebus/ServiceBusConsumer.java:
##########
@@ -342,9 +342,11 @@ public void run() {
                     continue;
                 }
 
-                // renew if lock is approaching expiry
+                // renew if the lock expires before the run after the next 
one: the period task scheduler runs this
+                // task every LOCK_RENEW_INTERVAL_SECONDS or a second later, 
so waiting for the next run when the lock
+                // expires within one interval can be too late, and the 
renewal itself is a call to Service Bus
                 Instant lockExpiry = entry.lockedUntil.toInstant();
-                if 
(now.plusSeconds(LOCK_RENEW_INTERVAL_SECONDS).isAfter(lockExpiry)) {
+                if (now.plusSeconds(2L * 
LOCK_RENEW_INTERVAL_SECONDS).isAfter(lockExpiry)) {

Review Comment:
   Fine as is. A related limit for a possible follow-up, which this change does 
not cause: Service Bus allows a lock duration as short as 5 seconds. With the 
renewer running only every 10 to 11 seconds, locks of about 11 seconds or less 
still cannot be kept, because each renewal only extends the lock by its own 
duration. Running the renewer more often (for example every 1 to 2 seconds, 
with the window scaled to the period) would cover short lock durations too. It 
costs little, since a run only calls Service Bus for the locks that are close 
to expiry.



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to