public static boolean isRetryableException(Exception exception) { if (exception == null) { throw new IllegalArgumentException("exception cannot be null"); } if (exception instanceof EventHubException) { return ((EventHubException) exception).getIsTransient(); } return false; }
private void drainPendingReceives(final Exception exception) { WorkItem<Collection<Message>> workItem; final boolean shouldReturnNull = (exception == null || (exception instanceof EventHubException && ((EventHubException) exception).getIsTransient())); while ((workItem = this.pendingReceives.poll()) != null) { final CompletableFuture<Collection<Message>> future = workItem.getWork(); if (shouldReturnNull) { future.complete(null); } else { ExceptionUtil.completeExceptionally(future, exception, this); } } }
@Override public void onError(Throwable throwable) { errorRate.inc(); aggReadErrors.inc(); if (throwable instanceof EventHubException) { EventHubException busException = (EventHubException) throwable; if (busException.getIsTransient()) { LOG.warn( String.format("Received transient exception from EH client. Renew partition receiver for ssp: %s", ssp), throwable); try { // Add a fixed delay so that we don't keep retrying when there are long-lasting failures Thread.sleep(Duration.ofSeconds(2).toMillis()); } catch (InterruptedException e) { LOG.warn("Interrupted during sleep before renew", e); } // Retry creating a receiver since error likely due to timeout renewPartitionReceiver(ssp); return; } } LOG.error(String.format("Received non transient exception from EH client for ssp: %s", ssp), throwable); // Propagate non transient or unknown errors eventHubNonTransientError.set(throwable); } }
&& !((EventHubException) completionException).getIsTransient()) { this.cancelOpen(completionException);
} else if (exception instanceof EventHubException && !((EventHubException) exception).getIsTransient()) { this.cancelOpen(exception);