From 87ea2480b6585ca6bad689d61ce706f17115fd66 Mon Sep 17 00:00:00 2001 From: Vijaya Gopal Yarramneni Date: Mon, 26 Oct 2020 14:53:09 -0700 Subject: [PATCH] Removing the sleep before retrying to accept session when the last attempt was not successful. --- .../azure/servicebus/MessageAndSessionPump.java | 9 +++------ 1 file changed, 3 insertions(+), 6 deletions(-) diff --git a/sdk/servicebus/microsoft-azure-servicebus/src/main/java/com/microsoft/azure/servicebus/MessageAndSessionPump.java b/sdk/servicebus/microsoft-azure-servicebus/src/main/java/com/microsoft/azure/servicebus/MessageAndSessionPump.java index 7ac9133fcaefc..6604c793e4fdd 100644 --- a/sdk/servicebus/microsoft-azure-servicebus/src/main/java/com/microsoft/azure/servicebus/MessageAndSessionPump.java +++ b/sdk/servicebus/microsoft-azure-servicebus/src/main/java/com/microsoft/azure/servicebus/MessageAndSessionPump.java @@ -32,7 +32,6 @@ class MessageAndSessionPump extends InitializableEntity implements IMessageAndSe private static final Logger TRACE_LOGGER = LoggerFactory.getLogger(MessageAndSessionPump.class); private static final Duration MINIMUM_MESSAGE_LOCK_VALIDITY = Duration.ofSeconds(4); private static final Duration MAXIMUM_RENEW_LOCK_BUFFER = Duration.ofSeconds(10); - private static final Duration SLEEP_DURATION_ON_ACCEPT_SESSION_EXCEPTION = Duration.ofMinutes(1); private static final int UNSET_PREFETCH_COUNT = -1; // Means prefetch count not set private static final CompletableFuture COMPLETED_FUTURE = CompletableFuture.completedFuture(null); @@ -259,11 +258,9 @@ private void acceptSessionAndPumpMessages() { if (!(acceptSessionEx instanceof OperationCancelledException)) { // don't retry if OperationCancelled by service.. may be entity itself is deleted - // In case of any other exception, sleep and retry - TRACE_LOGGER.debug("AcceptSession from entity '{}' will be retried after '{}'.", this.entityPath, SLEEP_DURATION_ON_ACCEPT_SESSION_EXCEPTION); - Timer.schedule(() -> { - MessageAndSessionPump.this.acceptSessionAndPumpMessages(); - }, SLEEP_DURATION_ON_ACCEPT_SESSION_EXCEPTION, TimerType.OneTimeRun); + // In case of any other exception, retry + TRACE_LOGGER.debug("Retrying to acceptSession from entity '{}'.", this.entityPath); + this.acceptSessionAndPumpMessages(); } } else { // Received a session.. Now pump messages..