You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardexpand all lines: spring-kafka-docs/src/main/antora/modules/ROOT/pages/retrytopic/how-the-pattern-works.adoc
+2
Original file line number
Diff line number
Diff line change
@@ -6,6 +6,8 @@ The retry topic consumer then checks the timestamp and if it's not due it pauses
6
6
When it is due the partition consumption is resumed, and the message is consumed again.
7
7
If the message processing fails again the message will be forwarded to the next retry topic, and the pattern is repeated until a successful processing occurs, or the attempts are exhausted, and the message is sent to the Dead Letter Topic (if configured).
8
8
9
+
NOTE: Starting with version 3.2, the default behavior is to reuse the retry topic for the same intervals.
10
+
9
11
To illustrate, if you have a "main-topic" topic, and want to set up non-blocking retry with an exponential backoff of 1000ms with a multiplier of 2 and 4 max attempts, it will create the main-topic-retry-1000, main-topic-retry-2000, main-topic-retry-4000 and main-topic-dlt topics and configure the respective consumers.
10
12
The framework also takes care of creating the topics and setting up and configuring the listeners.
NOTE: The default behavior is to create separate retry topics for each attempt, appended with an indexvalue: retry-0, retry-1, ..., retry-n.
13
-
Therefore, by default the number of retry topics is the configured `maxAttempts` minus 1.
12
+
NOTE: Starting with version 3.2, the default behavior is to reuse the retry topic for the same intervals. Alternatively, you can configure separate retry topics for each attempt, appended with an index(or delay) value: retry-0, retry-1, ..., retry-n, by using `SameIntervalTopicReuseStrategy.MULTIPLE_TOPICS`.
13
+
If you choose this strategy, the number of retry topics will, by default, be `maxAttempts` minus 1.
14
14
15
15
You can xref:retrytopic/topic-naming.adoc#retry-topics-and-dlt-suffixes[configure the suffixes], choose whether to append xref:retrytopic/topic-naming.adoc#append-index-or-delay[the attempt index or delay], use a xref:retrytopic/topic-naming.adoc#single-topic-fixed-delay[single retry topic when using fixed backoff], and use a xref:retrytopic/topic-naming.adoc#single-topic-maxinterval-delay[single retry topic for the attempts with the maxInterval] when using exponential backoffs.
16
16
@@ -69,8 +69,8 @@ public RetryTopicConfiguration myRetryTopic(KafkaTemplate<String, MyPojo> templa
69
69
70
70
NOTE: The default behavior is to suffix with the delay values, except for fixed delay configurations with multiple topics, in which case the topics are suffixed with the topic's index.
71
71
72
-
[[single-topic-fixed-delay]]
73
-
== Single Topic for Fixed Delay Retries
72
+
[[topic-strategies-for-fixed-delay]]
73
+
== Topic Strategies for Fixed Delay Retries
74
74
75
75
If you're using fixed delay policies such as `FixedBackOffPolicy` or `NoBackOffPolicy` you can use a single topic to accomplish the non-blocking retries.
76
76
This topic will be suffixed with the provided or default suffix, and will not have either the index or the delay values appended.
@@ -79,39 +79,64 @@ NOTE: The previous `FixedDelayStrategy` is now deprecated, and can be replaced b
== Topic Strategies for maxInterval Exponential Delay
107
132
108
133
If you're using exponential backoff policy (`ExponentialBackOffPolicy`), you can use a single retry topic to accomplish the non-blocking retries of the attempts whose delays are the configured `maxInterval`.
109
134
110
135
This "final" retry topic will be suffixed with the provided or default suffix, and will have either the index or the `maxInterval` value appended.
111
136
112
137
NOTE: By opting to use a single topic for the retries with the `maxInterval` delay, it may become more viable to configure an exponential retry policy that keeps retrying for a long time, because in this approach you do not need a large amount of topics.
113
138
114
-
Starting 3.2, the default behavior is reuses the retry topic for the same intervals, when using exponential backoff, the retry topics are suffixed with the delay values, with the last retry topic reuses for the same intervals(corresponding to the `maxInterval` delay).
139
+
Starting with version 3.2, the default behavior is to reuse the retry topic for the same intervals. When using exponential backoff, the retry topics are suffixed with the delay values, with the last retry topic being reused for the same intervals(corresponding to the `maxInterval` delay).
115
140
116
141
For instance, when configuring the exponential backoff with `initialInterval=1_000`, `multiplier=2`, and `maxInterval=16_000`, in order to keep trying for one hour, one would need to configure `maxAttempts` as 229, and by default the needed retry topics would be:
117
142
@@ -151,10 +176,10 @@ public void processMessage(MyPojo message) {
151
176
@Bean
152
177
public RetryTopicConfiguration myRetryTopic(KafkaTemplate<String, MyPojo> template) {
Copy file name to clipboardexpand all lines: spring-kafka/src/test/java/org/springframework/kafka/retrytopic/AsyncCompletableFutureRetryTopicClassLevelIntegrationTests.java
+2-2
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
/*
2
-
* Copyright 2024 the original author or authors.
2
+
* Copyright 2024-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
Copy file name to clipboardexpand all lines: spring-kafka/src/test/java/org/springframework/kafka/retrytopic/AsyncCompletableFutureRetryTopicScenarioTests.java
+2-2
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
/*
2
-
* Copyright 2024 the original author or authors.
2
+
* Copyright 2024-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
Copy file name to clipboardexpand all lines: spring-kafka/src/test/java/org/springframework/kafka/retrytopic/AsyncMonoFutureRetryTopicClassLevelIntegrationTests.java
+2-2
Original file line number
Diff line number
Diff line change
@@ -1,5 +1,5 @@
1
1
/*
2
-
* Copyright 2024 the original author or authors.
2
+
* Copyright 2024-2025 the original author or authors.
3
3
*
4
4
* Licensed under the Apache License, Version 2.0 (the "License");
5
5
* you may not use this file except in compliance with the License.
0 commit comments