Rename maxAttempts to maxRetries in @Retryable and RetryPolicy
Prior to this commit, the maximum number of retry attempts was
configured via @Retryable(maxAttempts = ...),
RetryPolicy.withMaxAttempts(), and RetryPolicy.Builder.maxAttempts().
However, this led to confusion for developers who were unsure if
"max attempts" referred to the "total attempts" (i.e., initial attempt
plus retry attempts) or only the "retry attempts".
To improve the programming model, this commit renames maxAttempts to
maxRetries in @Retryable and RetryPolicy.Builder and renames
RetryPolicy.withMaxAttempts() to RetryPolicy.withMaxRetries(). In
addition, this commit updates the documentation to consistently point
out that total attempts = 1 initial attempt + maxRetries attempts.
Closes gh-35772
For example, if `maxRetries` is set to `4`, the `@Retryable` method will be invoked at
least once and at most 5 times.
====
This can be specifically adapted for every method if necessary — for example, by narrowing
the exceptions to retry via the `includes` and `excludes` attributes. The supplied
@ -53,13 +64,13 @@ Custom predicates can be combined with `includes` and `excludes`; however, custo
@@ -53,13 +64,13 @@ Custom predicates can be combined with `includes` and `excludes`; however, custo
predicates will always be applied after `includes` and `excludes` have been applied.
====
Or for 5 retry attempts and an exponential back-off strategy with a bit of jitter:
Or for 4 retry attempts and an exponential back-off strategy with a bit of jitter:
[source,java,indent=0,subs="verbatim,quotes"]
----
@Retryable(
includes = MessageDeliveryException.class,
maxAttempts = 5,
maxRetries = 4,
delay = 100,
jitter = 10,
multiplier = 2,
@ -74,7 +85,7 @@ type, decorating the pipeline with Reactor's retry capabilities:
@@ -74,7 +85,7 @@ type, decorating the pipeline with Reactor's retry capabilities:
If you need to narrow the types of exceptions to retry, that can be achieved via the
`includes()` and `excludes()` builder methods. The supplied exception types will be
@ -213,14 +235,14 @@ Custom predicates can be combined with `includes` and `excludes`; however, custo
@@ -213,14 +235,14 @@ Custom predicates can be combined with `includes` and `excludes`; however, custo
predicates will always be applied after `includes` and `excludes` have been applied.
====
The following example demonstrates how to configure a `RetryPolicy` with 5 retry attempts
The following example demonstrates how to configure a `RetryPolicy` with 4 retry attempts
and an exponential back-off strategy with a bit of jitter.
@ -98,7 +98,7 @@ public class RetryAnnotationBeanPostProcessor extends AbstractBeanFactoryAwareAd
@@ -98,7 +98,7 @@ public class RetryAnnotationBeanPostProcessor extends AbstractBeanFactoryAwareAd