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: src/reference/asciidoc/kafka.adoc
+8-4Lines changed: 8 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -246,6 +246,8 @@ public void sendToKafka(final MyOutputData data) {
246
246
[[transactions]]
247
247
===== Transactions
248
248
249
+
====== Overview
250
+
249
251
The 0.11.0.0 client library added support for transactions.
250
252
Spring for Apache Kafka adds support in several ways.
251
253
@@ -273,11 +275,13 @@ If a transaction is active, any `KafkaTemplate` operations performed within the
273
275
The manager will commit or rollback the transaction depending on success or failure.
274
276
The `KafkaTemplate` must be configured to use the same `ProducerFactory` as the transaction manager.
275
277
276
-
====== Transactional Listener Container
278
+
====== Transactional Listener Container and Exactly Once Processing
277
279
278
-
You can provide a listener container with a `KafkaTransactionManager` instance; when so configured, the container will start a transaction before invoking the listener.
280
+
You can provide a listener container with a `KafkaAwareTransactionManager` instance; when so configured, the container will start a transaction before invoking the listener.
281
+
Any `KafkaTemplate` operations performed by the listener will participate in the transaction.
279
282
If the listener successfully processes the record (or records when using a `BatchMessageListener`), the container will send the offset(s) to the transaction using `producer.sendOffsetsToTransaction()`), before the transaction manager commits the transaction.
280
-
If the listener throws an exception, the transaction is rolled back and the consumer is repositioned so that the rolled-back records will be retrieved on the next poll.
283
+
If the listener throws an exception, the transaction is rolled back and the consumer is repositioned so that the rolled-back record(s) will be retrieved on the next poll.
284
+
See <<after-rollback>> for more information and for handling records that repeatedly fail.
281
285
282
286
====== Transaction Synchronization
283
287
@@ -2195,7 +2199,7 @@ This is to cause the transaction to roll back (if transactions are enabled).
2195
2199
[[after-rollback]]
2196
2200
===== After Rollback Processor
2197
2201
2198
-
When using transactions, if the listener container throws an exception (and an error handler, if present, throws an exception), the transaction is rolled back.
2202
+
When using transactions, if the listener throws an exception (and an error handler, if present, throws an exception), the transaction is rolled back.
2199
2203
By default, any unprocessed records (including the failed record) will be re-fetched on the next poll.
2200
2204
This is achieved by performing `seek` operations in the `DefaultAfterRollbackProcessor`.
2201
2205
With a batch listener, the entire batch of records will be reprocessed (the container has no knowledge of which record in the batch failed).
0 commit comments