Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Problem with exponential backoff in Spring Retry – delayExpression doesn't work with multiplierExpression

I’m trying to add retries to my calls using Spring Retry (newest version).

I’ve added the following annotation:

@Retryable( maxAttemptsExpression = "${retry.app.maxAttempts}",
            backoff = @Backoff(delayExpression = "${retry.app.backOffDelay}",
            multiplierExpression = "${retry.app.multiplier}"))
@Target({ ElementType.METHOD, ElementType.TYPE })
@Retention(RetentionPolicy.RUNTIME)
@Documented
public @interface AppRetryable {
}

and applied it to my HTTP client (Feign).

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

The values for retryable are defined in the following properties:

retry:
  app:
    multiplier: 2
    backOffDelay: 10000
    maxAttempts: 3

The problem is that while it generally works fine (the calls are being retried every 10s for 3 times) the time doesn’t grow exponentially.

I’ve noticed that if replace delayExpression and multiplierExpression with delay and multiplier and add hardcoded values it works fine. What is more is that replacing just delayExpression also works fine.

In other words:

        backoff = @Backoff(delay = 10000,
        multiplier = 2))

works fine.

And this one is fine too:

        backoff = @Backoff(delay = 10000,
        multiplierExpression = "${retry.app.multiplier}"))

But not:

        backoff = @Backoff(delayExpression = "${retry.app.backOffDelay}",
        multiplierExpression = "${retry.app.multiplier}"))

Is there anything I’m doing wrong or there is a bug in the library?

>Solution :

There is a recent fix for this (not yet released).

https://github.com/spring-projects/spring-retry/issues/397

Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading