@@ -70,12 +70,12 @@ Or for 4 retry attempts and an exponential back-off strategy with a bit of jitte
7070[source,java,indent=0,subs="verbatim,quotes"]
7171----
7272@Retryable(
73- includes = MessageDeliveryException.class,
74- maxRetries = 4,
75- delay = 100,
76- jitter = 10,
77- multiplier = 2,
78- maxDelay = 1000)
73+ includes = MessageDeliveryException.class,
74+ maxRetries = 4,
75+ delay = 100,
76+ jitter = 10,
77+ multiplier = 2,
78+ maxDelay = 1000)
7979public void sendNotification() {
8080 this.jmsClient.destination("notifications").send(...);
8181}
@@ -324,7 +324,7 @@ outcome of all attempts:
324324[source,java,indent=0,subs="verbatim,quotes"]
325325----
326326 try {
327- var result = new RetryTemplate() .execute(() -> {
327+ var result = retryTemplate .execute(() -> {
328328 jmsClient.destination("notifications").send(...);
329329 return "result";
330330 });
@@ -335,16 +335,21 @@ outcome of all attempts:
335335----
336336
337337A {spring-framework-api}/core/retry/RetryListener.html[`RetryListener`] can be registered
338- with a `RetryTemplate` to react to events published during key retry phases (before a
339- retry attempt, after a retry attempt, etc.), being able to track all invocation attempts
340- and all exceptions coming out of the callback. This is particularly useful when using
341- `invoke` where no retry state other than the last original exception is exposed otherwise:
338+ with a `RetryTemplate` to react to key retry steps (before or after a retry attempt etc.)
339+ or simply to every invocation attempt, being able to track all exceptions coming out of
340+ the callback and all retry outcomes (exhaustion, interruption, timeout). This is
341+ particularly useful when using `invoke` where no retry state other than the last
342+ original exception is exposed otherwise:
342343
343344[source,java,indent=0,subs="verbatim,quotes"]
344345----
345346 var retryTemplate = new RetryTemplate();
346- retryTemplate.setRetryPolicy(...);
347- retryTemplate.setRetryListener(...);
347+ retryTemplate.setRetryListener(new RetryListener() {
348+ @Override
349+ public void onRetryableExecution(RetryPolicy retryPolicy, Retryable<?> retryable, RetryState retryState) {
350+ ...
351+ }
352+ });
348353
349354 retryTemplate.invoke(
350355 () -> jmsClient.destination("notifications").send(...));
0 commit comments