'How to record each throwable when using .onFailure().retry() with delay between retries

I need to record failure reason in metrics for each failed http call when using Vert.x WebClient. This compiles:

               .onFailure()
                   .retry()
                   .withBackOff(Duration.ofMillis(INITIAL_RETRY_DELAY_MS))
                   .until(retryTimeExpired(wrapper))

I'm recording metrics in retryTimeExpired method. But at runtime I get this:

Caused by: java.lang.IllegalArgumentException: Invalid retry configuration, `when` cannot be used with a back-off configuration
    at io.smallrye.mutiny.groups.UniRetry.when(UniRetry.java:156)
    at io.smallrye.mutiny.groups.UniRetry.until(UniRetry.java:137)

I could of course add sleep but this is reactive. It would be possible to block for a short time but I would hate to block the thread. Any ideas how to do this without sleep?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source