Quick revision
The short answer
In Spring Framework 7 we enable method-level resilience with @EnableResilientMethods and annotate the method with @Retryable from org.springframework.resilience.annotation, choosing which exceptions to retry, how many retries, and a delay with exponential backoff and jitter; @ConcurrencyLimit in the same package caps parallel calls. A programmatic RetryTemplate lives in the core retry package for code that cannot use annotations. Because the feature is proxy-based, a call from inside the same class is not retried, and we only retry idempotent operations with a cap on total time so retries do not amplify an outage.
What to remember
In this answer, we enabled Framework 7's built-in resilience with @EnableResilientMethods, retried a flaky call with @Retryable from org.springframework.resilience.annotation using selected exceptions, a bounded number of retries and exponential backoff with jitter, and capped parallel calls with @ConcurrencyLimit. We saw that the proxy-based design means self-invocation is not retried, that RetryTemplate in the core retry package covers programmatic cases, and that we only retry idempotent operations with a cap on total time.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
In Spring Framework 7 we enable method-level resilience with @EnableResilientMethods and annotate the method with @Retryable from org.springframework.resilience.annotation, choosing which exceptions to retry, how many retries, and a delay with exponential backoff and jitter; @ConcurrencyLimit in the same package caps parallel calls. A programmatic RetryTemplate lives in the core retry package for code that cannot use annotations. Because the feature is proxy-based, a call from inside the same class is not retried, and we only retry idempotent operations with a cap on total time so retries do not amplify an outage.
Why this question is asked
Calls to other services fail occasionally for reasons that go away a moment later: a connection reset, a pod restarting, a brief overload. A short retry turns many of those failures into successes the user never notices. For years this needed the separate Spring Retry project or Resilience4j; Spring Framework 7 brings basic retry and concurrency limiting into the core framework. Interviewers ask for it in a coding round because the code is short, but the details, what to retry, how long to wait and when retrying is harmful, separate a careful engineer from one who copies an annotation. In this answer, we will enable the feature, add a retry to a flaky call, see how the proxy applies it, use the programmatic RetryTemplate, and look at the safety rules and what to verify in the release notes.
1A Quick Recap of Retries and Backoff
A retry calls the same operation again after a failure. Retrying immediately is usually a bad idea, because whatever caused the failure is probably still there, so we wait between attempts. Exponential backoff means each wait is longer than the previous one, for example 200 ms, then 400 ms, then 800 ms. Jitter adds a small random amount to each wait, so that a thousand clients that failed at the same moment do not all retry at exactly the same moment and knock the service over again.
2Enabling the Feature and Adding @Retryable
Method-level resilience is switched on with @EnableResilientMethods on a configuration class. We then annotate the method that calls the flaky service. The attribute names below follow the Framework 7 reference; they changed during the milestones, so check them for your version.
Notice that we retry only ResourceAccessException, which RestClient throws for connection problems and timeouts. A 400 Bad Request will fail the same way every time, so retrying it only wastes time. If all attempts fail, the last exception reaches the caller.
3How the Proxy Applies the Retry
@EnableResilientMethods registers a post-processor that wraps beans having these annotations in a proxy, a generated object that sits in front of our bean. When another bean calls fetch(), the call reaches the proxy, which runs the method and, on a matching exception, waits and calls it again.
9 messages in order. Play them, or step through them one at a time.
4The Self-Invocation Trap
Because the retry lives in the proxy, a call that does not pass through the proxy is not retried. That is the same rule as for @Transactional.
The fix is the usual one: call fetch() from another bean, or move the retried call into its own small bean that PriceClient injects.
5The Programmatic RetryTemplate
Sometimes an annotation does not fit, for example when the retry policy comes from configuration at runtime or we retry only one block of a longer method. Framework 7 has a RetryTemplate in the core retry package, org.springframework.core.retry, configured with a RetryPolicy.
The builder method names should be checked against your exact version, as they were refined before the 7.0 release.
6When Retrying Is Safe, and What to Verify
Only retry operations that are idempotent, meaning that running them twice has the same effect as running them once. A GET of a price is safe. A POST that charges a card is not, unless the server accepts an idempotency key and ignores duplicates. We also cap the total time: with a 2 second read timeout and three retries, one call could take more than 9 seconds, four attempts of 2 seconds plus the waits between them, which may already exceed the caller's own timeout. In an outage, every caller retrying three times quadruples the load on a struggling service, so keep the number of retries small and combine it with timeouts.
In the release notes and reference documentation, verify the exact attribute names and defaults of @Retryable, how maxRetries is counted, how reactive return types such as Mono are handled, whether @ConcurrencyLimit blocks or rejects when the limit is reached, and which observability or listener hooks exist for counting retries.
7Follow-up questions
How does this relate to the separate Spring Retry project?
Spring Retry was the long-standing separate library with its own @Retryable and @EnableRetry, built on RetryTemplate and AOP. Framework 7 brings the common parts into the core framework with a simpler, modern API, and Spring Retry is in maintenance mode, so new code should use the core features. The annotations have the same name but live in different packages, so during a migration we must make sure we import org.springframework.resilience.annotation.Retryable and enable it with @EnableResilientMethods.
Should I retry on HTTP 503?
Often yes, because 503 Service Unavailable usually means a temporary condition, and the server may even send a Retry-After header. I would add HttpServerErrorException.ServiceUnavailable to the included exceptions, but not 500, which often signals a bug that a retry will not fix.
Do retries replace a circuit breaker?
No. Retries handle short, isolated failures. When a service is down for minutes, a circuit breaker stops calling it at all for a while, which protects both sides. The core framework does not provide a circuit breaker, so for that we still use a library such as Resilience4j.
8Conclusion
In this answer, we enabled Framework 7's built-in resilience with @EnableResilientMethods, retried a flaky call with @Retryable from org.springframework.resilience.annotation using selected exceptions, a bounded number of retries and exponential backoff with jitter, and capped parallel calls with @ConcurrencyLimit. We saw that the proxy-based design means self-invocation is not retried, that RetryTemplate in the core retry package covers programmatic cases, and that we only retry idempotent operations with a cap on total time.
Open with
In Framework 7, I put @EnableResilientMethods on a configuration class, and on the method that calls the flaky service I add @Retryable from org.springframework.resilience.annotation. I would restrict it to the exceptions that are worth retrying, like ResourceAccessException for connection errors and timeouts, and maybe a 503, never a 400.
Then, if they want more
Then I set a small number of retries, say three, with a delay of around 200 milliseconds, a multiplier of two for exponential backoff, some jitter so clients do not retry in lockstep, and a maximum delay. If I also want to protect the downstream service, @ConcurrencyLimit caps how many calls are in flight.
It works through a proxy, so a call from inside the same class is not retried, exactly like @Transactional; I would call it from another bean. For cases where an annotation does not fit, there is a RetryTemplate in the core retry package with a RetryPolicy builder.
Two safety rules matter most: only retry idempotent operations, or use idempotency keys, and cap the total time, since timeouts times retries can exceed the caller's own deadline and retries multiply load during an outage. In the release notes I would verify the attribute names and defaults, how retries are counted, reactive support, and what happens at the concurrency limit.
About this answer
- Last updated
- 12 November 2026
- Versions it names
- Spring Framework 7
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Spring Framework reference, Core technologies
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Spring Framework 7 includes resilience features in the core framework. Show how you...": https://scrivio-interview-library.netlify.app/spring-boot/spring-framework-evolution/d03fd5d7a5/