Add resilience: Spring Framework 7 @Retryable and @ConcurrencyLimit
Companion code for "Spring Framework 7's Built-in Resilience: @Retryable, @ConcurrencyLimit, and What's Left for Resilience4j". Every retry counted by recording real invocations: defaults, backoff and jitter, timeout, reactive and CompletableFuture returns, the concurrency limit's BLOCK and REJECT policies, retries around transactions, composition with Resilience4j 2.4.0, and the annotation API across 7.0.0-7.0.9. Co-Authored-By: Claude Opus 5 <[email protected]> Claude-Session: https://claude.ai/code/session_01C3TETMrqVUWeFkNtz3Jbo3
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
# 7. Migrating from spring-retry
|
||||
|
||||
[← 6. What is left for Resilience4j](06-what-is-left-for-resilience4j.md) · [Index](../README.md)
|
||||
|
||||
The spring-retry README now says the project "is no longer maintained as an open-source project"
|
||||
and "has been superseded by Spring Framework 7". Its last release on Maven Central is 2.0.13.
|
||||
|
||||
| spring-retry | Spring Framework 7 | Watch out |
|
||||
|---|---|---|
|
||||
| `@EnableRetry` | `@EnableResilientMethods` | |
|
||||
| `@Retryable(maxAttempts = 3)` | `@Retryable(maxRetries = 2)` | **attempts vs retries** - `maxRetries = 3` is one call more |
|
||||
| `@Retryable(retryFor = X.class)` | `@Retryable(includes = X.class)` (or `value`) | causes are matched too |
|
||||
| `@Retryable(noRetryFor = X.class)` | `@Retryable(excludes = X.class)` | |
|
||||
| `@Backoff(delay, multiplier, maxDelay)` | `delay`, `multiplier`, `maxDelay` attributes | default delay is 1000 ms in both |
|
||||
| `@Backoff(random = true)` | `jitter` | jitter only adds delay (chapter 3) |
|
||||
| `@Recover` | none - catch the exception in the caller | declined upstream |
|
||||
| `RetryTemplate.builder()` | `new RetryTemplate(RetryPolicy.builder()...build())` | `execute` throws `RetryException`; `invoke` throws the original |
|
||||
| stateful retry / `RetryContext` | none | |
|
||||
|
||||
Keep spring-retry on the classpath only as long as something still uses `@Recover` or stateful
|
||||
retry. Both libraries define an annotation named `Retryable` - check the import on every one.
|
||||
Reference in New Issue
Block a user