Skip to content

Commit e8ab82a

Browse files
authored
Add Spring Retry removal documentation to what's new
Documents the breaking change from removing Spring Retry dependency in favor of Spring Framework 7's core retry support in the whats-new doc. Covers the main changes including `BackOffValuesGenerator` updates, new `BackOff` annotation, `RetryingDeserializer` API changes, and `ExceptionMatcher` replacement for `BinaryExceptionClassifier`. Includes migration examples and guidance for updating `RetryableTopic` configurations from `Backoff` to `BackOff` annotation. Signed-off-by: Soby Chacko <[email protected]>
1 parent 04d1ca6 commit e8ab82a

File tree

1 file changed

+60
-0
lines changed

1 file changed

+60
-0
lines changed

spring-kafka-docs/src/main/antora/modules/ROOT/pages/whats-new.adoc

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,3 +121,63 @@ The framework automatically detects and prefers Jackson 3 when both versions are
121121
They will be removed in a future major version.
122122

123123
See xref:kafka/serdes.adoc[Serialization, Deserialization, and Message Conversion] for configuration examples.
124+
125+
[[x40-spring-retry-replacement]]
126+
=== Spring Retry Dependency Removal
127+
128+
Spring for Apache Kafka has removed its dependency on Spring Retry in favor of the core retry support introduced in Spring Framework 7.
129+
This is a breaking change that affects retry configuration and APIs throughout the framework.
130+
131+
`BackOffValuesGenerator` that generates the required `BackOff` values upfront, now works directly with Spring Framework's `BackOff` interface instead of `BackOffPolicy`.
132+
These values are then managed by the listener infrastructure and Spring Retry is no longer involved.
133+
134+
From a configuration standpoint, Spring Kafka relied heavily on Spring Retry's `@Backoff` annotation.
135+
As there is no equivalent in Spring Framework, the annotation has been moved to Spring Kafka as `@BackOff` with the following improvements:
136+
137+
* Harmonized naming: Uses `@BackOff` instead of `@Backoff` for consistency
138+
* Expression evaluation: All string attributes support SpEL expressions and property placeholders
139+
* Duration format support: String attributes accept `java.util.Duration` formats (e.g., "2s", "500ms")
140+
* Enhanced documentation: Improved Javadoc with clearer explanations
141+
142+
Migration example:
143+
[source,java]
144+
----
145+
// Before
146+
@RetryableTopic(backoff = @Backoff(delay = 2000, maxDelay = 10000, multiplier = 2))
147+
148+
// After
149+
@RetryableTopic(backOff = @BackOff(delay = 2000, maxDelay = 10000, multiplier = 2))
150+
151+
// With new duration format support
152+
@RetryableTopic(backOff = @BackOff(delayString = "2s", maxDelayString = "10s", multiplier = 2))
153+
154+
// With property placeholders
155+
@RetryableTopic(backOff = @BackOff(delayString = "${retry.delay}", multiplierString = "${retry.multiplier}"))
156+
----
157+
158+
`RetryingDeserializer` no longer offers a `RecoveryCallback` but an equivalent function that takes `RetryException` as input.
159+
This contains the exceptions thrown as well as the number of retry attempts:
160+
161+
[source,java]
162+
----
163+
// Before
164+
retryingDeserializer.setRecoveryCallback(context -> {
165+
return fallbackValue;
166+
});
167+
168+
// After
169+
retryingDeserializer.setRecoveryCallback(retryException -> {
170+
return fallbackValue;
171+
});
172+
----
173+
174+
The use of `BinaryExceptionClassifier` has been replaced by the newly introduced `ExceptionMatcher`, which provides a polished API.
175+
176+
Additional changes include:
177+
178+
* `DestinationTopicPropertiesFactory` uses `ExceptionMatcher` instead of `BinaryExceptionClassifier`
179+
* The `uniformRandomBackoff` method in `RetryTopicConfigurationBuilder` has been deprecated in favor of jitter support
180+
* Error handling utilities have been updated to work with the new exception matching system
181+
* Kafka Streams retry templates now use Spring Framework's retry support
182+
183+
Applications must update their configuration to use the new Spring Framework retry APIs, but the retry behavior and functionality remain the same.

0 commit comments

Comments
 (0)