Skip to content

Commit

Permalink
new retry logic for service bus
Browse files Browse the repository at this point in the history
  • Loading branch information
Ivan Aladjoff authored and Ivan Aladjoff committed Nov 28, 2024
1 parent 5eaf13b commit 915a7dd
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ interface CheckedRunnable {
void run() throws Exception;
}

private static final Set<ServiceBusFailureReason> RETRIABLE_REASONS = Set.of(
private static final Set<ServiceBusFailureReason> RETRYABLE_REASONS = Set.of(
ServiceBusFailureReason.GENERAL_ERROR,
ServiceBusFailureReason.QUOTA_EXCEEDED,
ServiceBusFailureReason.SERVICE_BUSY,
Expand All @@ -59,7 +59,7 @@ interface CheckedRunnable {
ServiceBusFailureReason.SESSION_CANNOT_BE_LOCKED
);

private static final Set<ServiceBusFailureReason> NON_RETRIABLE_REASONS = Set.of(
private static final Set<ServiceBusFailureReason> NON_RETRYABLE_REASONS = Set.of(
ServiceBusFailureReason.MESSAGING_ENTITY_NOT_FOUND,
ServiceBusFailureReason.MESSAGING_ENTITY_DISABLED,
ServiceBusFailureReason.MESSAGE_SIZE_EXCEEDED,
Expand Down Expand Up @@ -227,8 +227,8 @@ protected void executeWithRetry(CheckedRunnable task, String description) throws
LOG.warn("{} failed. Error: {} (Attempt {})", description, e.getMessage(), attemptCounter);

if (!shouldRetry(e)) {
LOG.error("{} encountered a non-retriable error: {}.", description, e.getMessage());
throw e; // Stop retries if the error is non-retriable
LOG.error("{} encountered a non-retryable error: {}.", description, e.getMessage());
throw e; // Stop retries if the error is non-retryable
}

LOG.warn("{} will retry in {} ms.", description, sleepPeriod);
Expand All @@ -249,12 +249,12 @@ protected boolean shouldRetry(Exception e) {
if (e instanceof ServiceBusException sbException) {
ServiceBusFailureReason reason = sbException.getReason();

if (RETRIABLE_REASONS.contains(reason)) {
if (RETRYABLE_REASONS.contains(reason)) {

LOG.warn("Transient error encountered: {}. Retrying...", reason);
return true;

} else if (NON_RETRIABLE_REASONS.contains(reason)) {
} else if (NON_RETRYABLE_REASONS.contains(reason)) {

LOG.error("Non-recoverable error encountered: {}. Not retrying.", reason);
return false;
Expand Down
3 changes: 1 addition & 2 deletions doc/user/sandbox/siri/SiriAzureUpdater.md
Original file line number Diff line number Diff line change
Expand Up @@ -199,5 +199,4 @@ Has to be present for authenticationMethod SharedAccessKey. This should be Prima
- Minor changes in logging (November 2022)
- Retry fetch from history endpoint if it failed (February 2023)
- Solve a bug in SiriAzureETUpdater and improve error logging (March 2023)
- Add support with federated identity authentication (February 2024)
- Changed topic and feedId to required (Nov 2024)
- Add support with federated identity authentication (February 2024)

0 comments on commit 915a7dd

Please sign in to comment.