in src/main/java/com/amazonaws/transcribestreaming/TranscribeStreamingRetryClient.java [155:191]
private void recursiveStartStream(final StartStreamTranscriptionRequest request,
final Publisher<AudioStream> publisher,
final StreamTranscriptionBehavior responseHandler,
final CompletableFuture<Void> finalFuture,
final int retryAttempt, final String channel) {
CompletableFuture<Void> result = client.startStreamTranscription(request, publisher,
getResponseHandler(responseHandler));
result.whenComplete((r, e) -> {
if (e != null) {
logger.debug("Error occurred on channel " + channel +" : " + e.getMessage());
e.printStackTrace();
if (retryAttempt <= maxRetries && isExceptionRetriable(e)) {
logger.debug("Retriable error occurred and will be retried.");
logger.debug("Sleeping for sometime before retrying...");
try {
Thread.sleep(sleepTime);
} catch (InterruptedException e1) {
logger.error("Sleep between retries interrupted. Failed with exception: ", e);
finalFuture.completeExceptionally(e);
}
logger.debug("Making retry attempt: " + (retryAttempt + 1));
recursiveStartStream(request, publisher, responseHandler, finalFuture, retryAttempt + 1, channel);
} else {
metricsUtil.recordMetric("TranscribeStreamError", 1);
logger.error("Encountered unretriable exception or ran out of retries.", e);
responseHandler.onError(e);
finalFuture.completeExceptionally(e);
}
} else {
logger.info("Completable future is complete.");
//metricsUtil.recordMetric("TranscribeStreamError", 0);
responseHandler.onComplete();
finalFuture.complete(null);
}
});
}