Hi,
I have the following code:
Mono mo = Mono.fromFuture(makeCompletableFuture(amazonDynamoDBAsync.getItemAsync(myGetRequest)));
The private method is as follows. Basically it restricts the Dynamo get operation to max of 1ms.
private static <T> CompletableFuture<T> makeCompletableFuture(@NonNull Future<T> future) {
System.out.println("Retrying ....");
return CompletableFuture.supplyAsync(() -> {
try {
return future.get(1,TimeUnit.MILLISECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
throw new RuntimeException(e);
}
});
}
In 99% of the cases, this code works. But sometimes the network latencies cause the get operation to exceed 1ms. I do not want to increase the Future.get() timeout to higher value. Rather I want to make this method retry if the Dynamo get does not complete within 1ms.
So I made the below change to use Retry from io.projectreactor.addons:reactor-extra::3.1.6.RELEASE
Retry retry = Retry.anyOf(CompletionException.class, RuntimeException.class, TimeoutException.class)
.timeout(Duration.ofMillis(10))
.retryMax(10);
Mono mo = Mono.fromFuture(makeCompletableFuture(amazonDynamoDBAsync.getItemAsync(myGetRequest)));
return mo.retryWhen(retry);
However, I do not see the Dynamo get operation being retried even if the get operation fails to complete in 1ms on Dynamo.
What is wrong here?
Thanks for your help.