Skip to content

Commit 7d628b6

Browse files
committed
Polish Resilience Features section of reference manual
1 parent dbe89ab commit 7d628b6

File tree

1 file changed

+24
-19
lines changed

1 file changed

+24
-19
lines changed

framework-docs/modules/ROOT/pages/core/resilience.adoc

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ in particular `@Retryable` and `@ConcurrencyLimit` annotations for method invoca
88
[[resilience-retryable]]
99
== Using `@Retryable`
1010

11-
`@Retryable` is a common annotation specifying retry characteristics for an individual
11+
`@Retryable` is a common annotation that specifies retry characteristics for an individual
1212
method (with the annotation declared at the method level), or for all proxy-invoked
1313
methods in a given class hierarchy (with the annotation declared at the type level).
1414

@@ -21,10 +21,10 @@ public void sendNotification() {
2121
----
2222

2323
By default, the method invocation will be retried for any exception thrown: with at
24-
most 3 retry attempts after an initial failure, and a delay of 1 second in-between.
24+
most 3 retry attempts after an initial failure, and a delay of 1 second between attempts.
2525

26-
This can be specifically adapted for every method if necessary, for example narrowing
27-
the exceptions to retry::
26+
This can be specifically adapted for every method if necessaryfor example, by narrowing
27+
the exceptions to retry:
2828

2929
[source,java,indent=0,subs="verbatim,quotes"]
3030
----
@@ -51,20 +51,23 @@ return type, decorating the pipeline with Reactor's retry capabilities:
5151
----
5252
@Retryable(maxAttempts = 5, delay = 100, jitter = 10, multiplier = 2, maxDelay = 1000)
5353
public Mono<Void> sendNotification() {
54-
return Mono.from(...); // this raw Mono will get decorated with a retry spec
54+
return Mono.from(...); // <1>
5555
}
5656
----
57-
57+
<1> This raw `Mono` will get decorated with a retry spec.
58+
5859
For details on the various characteristics, see the available annotation attributes
59-
on {spring-framework-api}/resilience/annotation/Retryable.html[`@Retryable`]. Note:
60-
There a String variants with placeholder support available for several attributes
61-
as well, as an alternative to the specifically typed annotation attributes above.
60+
in {spring-framework-api}/resilience/annotation/Retryable.html[`@Retryable`].
61+
62+
NOTE: There a `String` variants with placeholder support available for several attributes
63+
as well, as an alternative to the specifically typed annotation attributes used in the
64+
above examples.
6265

6366

6467
[[resilience-concurrency]]
6568
== Using `@ConcurrencyLimit`
6669

67-
`@ConcurrencyLimit` is an annotation specifying a concurrency limit for an individual
70+
`@ConcurrencyLimit` is an annotation that specifies a concurrency limit for an individual
6871
method (with the annotation declared at the method level), or for all proxy-invoked
6972
methods in a given class hierarchy (with the annotation declared at the type level).
7073

@@ -76,35 +79,37 @@ public void sendNotification() {
7679
}
7780
----
7881

79-
This is meant to protect the target resource from being accessed from too many
80-
threads at the same time, similar to the effect of a pool size limit in case of
81-
thread pool or of a connection pool that blocks access if its limit is reached.
82+
This is meant to protect the target resource from being accessed from too many threads at
83+
the same time, similar to the effect of a pool size limit for a thread pool or a
84+
connection pool that blocks access if its limit is reached.
8285

83-
At its most constrained, you may set the limit to 1, effectively locking access
84-
to the target bean instance:
86+
You may optionally set the limit to 1, effectively locking access to the target bean
87+
instance:
8588

8689
[source,java,indent=0,subs="verbatim,quotes"]
8790
----
88-
@ConcurrencyLimit(1) // 1 is the default but this makes it more readable
91+
@ConcurrencyLimit(1) // <1>
8992
public void sendNotification() {
9093
this.jmsClient.destination("notifications").send(...);
9194
}
9295
----
93-
96+
<1> 1 is the default, but specifying it makes the intent clearer.
97+
9498
Such limiting is particularly useful with Virtual Threads where there is generally
9599
no thread pool limit in place. For asynchronous tasks, this can be constrained on
96100
{spring-framework-api}/core/task/SimpleAsyncTaskExecutor.html[`SimpleAsyncTaskExecutor`].
97101
For synchronous invocations, this annotation provides equivalent behavior through
98102
{spring-framework-api}/aop/interceptor/ConcurrencyThrottleInterceptor.html[`ConcurrencyThrottleInterceptor`]
99-
which is available since Spring Framework 1.0 for programmatic use with the AOP framework.
103+
which has been available since Spring Framework 1.0 for programmatic use with the AOP
104+
framework.
100105

101106

102107
[[resilience-enable]]
103108
== Configuring `@EnableResilientMethods`
104109

105110
Note that like many of Spring's core annotation-based features, `@Retryable` and
106111
`@ConcurrencyLimit` are designed as metadata that you can choose to honor or ignore.
107-
The most convenient way of enabling actual processing of the resilience annotations
112+
The most convenient way to enable actual processing of the resilience annotations
108113
through AOP interception is to declare `@EnableResilientMethods` on a corresponding
109114
configuration class. Alternatively, you may declare `RetryAnnotationBeanPostProcessor`
110115
and/or `ConcurrencyLimitBeanPostProcessor` individually.

0 commit comments

Comments
 (0)