To implement attempts in any situation, check Failsafe :
RetryPolicy retryPolicy = new RetryPolicy()
.retryIf((ClientResponse response) -> response.getStatus() != 200)
.withDelay(1, TimeUnit.SECONDS)
.withMaxRetries(3);
Failsafe.with(retryPolicy).get(() -> webResource.post(ClientResponse.class, input));
This example repeats if the response status is! = 200, up to 3 times, with a delay of 1 second between attempts.
source
share