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
Non-blocking retries will break container transactions atomicity.
* Enable non-blocking retries and container transaction, when listener code threw error, catch by `DefaultErrorHandler` and recover success. Container transactions commit success and send record to a retryable topic.
* Desired behavior is Container transactions rollback, send offsets commit transaction success, send record to a retryable topic.
* Add adoc to notice.
see #2934
Copy file name to clipboardExpand all lines: spring-kafka-docs/src/main/antora/modules/ROOT/pages/kafka/transactions.adoc
+3-64Lines changed: 3 additions & 64 deletions
Original file line number
Diff line number
Diff line change
@@ -79,6 +79,9 @@ Instead, use a `KafkaTransactionManager` in the container to start the Kafka tra
79
79
80
80
See xref:tips.adoc#ex-jdbc-sync[Examples of Kafka Transactions with Other Transaction Managers] for an example application that chains JDBC and Kafka transactions.
81
81
82
+
IMPORTANT: Container transactions use xref:retrytopic.adoc[Non-Blocking Retries] will break transaction atomicity.
83
+
When listener code threw exception, container transactions commit success and record sending to the retryable topic.
84
+
82
85
[[kafkatemplate-local-transactions]]
83
86
== `KafkaTemplate` Local Transactions
84
87
@@ -209,67 +212,3 @@ public static class Config {
209
212
}
210
213
----
211
214
212
-
[[kafka-listener-nested-kafka-transactions]]
213
-
== Listeners Nested Kafka Transactions
214
-
215
-
IMPORTANT: xref:retrytopic.adoc[Non-Blocking Retries] are not supported Listeners Nested Kafka transactions.
216
-
Listeners enable transaction and Non-Blocking Retries, when listener fails after invoke `KafkaTemplate` Transactions.
217
-
`KafkaTemplate` transactions commit success multiple times because of exception catch by Non-Blocking Retries and not threw.
218
-
219
-
[source, java]
220
-
----
221
-
public static class TestListener {
222
-
223
-
@Autowired
224
-
KafkaTemplate<String, String> kafkaTemplate;
225
-
226
-
@RetryableTopic
227
-
@KafkaListener(topics = "tests")
228
-
void listen(String in) {
229
-
kafkaTemplate.send("nested-test-topic", "value");
230
-
throw new RuntimeException("from FirstRetryableKafkaListener");
231
-
}
232
-
233
-
}
234
-
235
-
@EnableKafka
236
-
@Configuration
237
-
static class Config {
238
-
239
-
@Bean
240
-
public TestListener test() {
241
-
return new TestListener();
242
-
}
243
-
244
-
@Bean
245
-
public ConsumerFactory<?, ?> consumerFactory() {
246
-
return mock(ConsumerFactory.class);
247
-
}
248
-
249
-
@Bean
250
-
public ConcurrentKafkaListenerContainerFactory<String, String> kafkaListenerContainerFactory() {
251
-
ConcurrentKafkaListenerContainerFactory factory = new ConcurrentKafkaListenerContainerFactory();
Copy file name to clipboardExpand all lines: spring-kafka-docs/src/main/antora/modules/ROOT/pages/retrytopic.adoc
+2-1Lines changed: 2 additions & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -9,4 +9,5 @@ Since 2.7 Spring for Apache Kafka offers support for that via the `@RetryableTop
9
9
10
10
IMPORTANT: Non-blocking retries are not supported with xref:kafka/receiving-messages/listener-annotation.adoc#batch-listeners[Batch Listeners].
11
11
12
-
IMPORTANT: Non-blocking retries are not supported xref:kafka/transactions.adoc#kafka-listener-nested-kafka-transactions[Listeners Nested Kafka Transactions].
12
+
13
+
IMPORTANT: xref:kafka/transactions.adoc#container-transaction-manager[Using Consumer-Initiated Transactions] use Non-Blocking Retries will break transaction atomicity.
Copy file name to clipboardExpand all lines: spring-kafka/src/test/java/org/springframework/kafka/retrytopic/RetryTopicTransactionIntegrationTests.java
0 commit comments