failsafe-lib/failsafe

Access wait time from failed attempt listener?

jansohn opened this issue · 2 comments

I'd like to log the wait time until next run will be started. As we use withBackoff() this time is not a constant value. Any way this can be achieved?

RetryPolicy<Server> retryPolicy = new RetryPolicy<Server>()
    .handle(Throwable.class)
    .withBackoff(INITIAL_RETRY_DELAY_IN_SECONDS, MAX_RETRY_DELAY_IN_SECONDS, ChronoUnit.SECONDS)
    .withMaxAttempts(REGISTER_MAX_ATTEMPTS)
    .onFailedAttempt(listener -> log.warn("Registering server '{}' attempt #{} failed: '{}'. Retrying in {} seconds...",
            serverUrl,
            listener.getAttemptCount(),
            listener.getLastFailure().getMessage(),
            listener.getXXX()));

We're currently using failsafe 2.4.4.

This has come up before (#232) but I was waiting to see if there was much interest. There are some caveats though, which are described here: #232 (comment). Any thoughts on those?

This has come up before (#232) but I was waiting to see if there was much interest. There are some caveats though, which are described here: #232 (comment). Any thoughts on those?

Thanks, was searching for the wrong keywords I guess. Closing in favor of your issue and already left a comment there!