Search code examples
springspring-webclientreactor-netty

Spring WebClient: What is the default multiplier for Retry.backoff?


I am trying to understand the the default multiplier for exponential backoff strategy for Spring WebClient Retry.backoff method. And can this be configured? I cannot find documentation for this.

https://projectreactor.io/docs/core/release/api/reactor/util/retry/Retry.html#backoff-long-java.time.Duration-

Version: reactor-netty 0.9.12.RELEASE


Solution

  • The utility method Retry.backoff, as you said correctly, creates an exponential backoff strategy. The multiplier is 2. In other words, the backoff period doubles in length on each retry/failure.

    You can see this in action in reactor.util.retry.RetryBackoffSpec#generateCompanion.

    The "multiplier", as you can see, is hardcoded and is therefore not configurable out-the-box. In order to use something other than 2 you would create your own Retry implementation and specifically implement the generateCompanion() method to do logic as is done in RetryBackoffSpec but using your own custom multiplier.