Skip to content

Commit 1a1cc29

Browse files
committed
GH-1621: Doc/Javadoc Polishing
1 parent 5c77905 commit 1a1cc29

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

spring-kafka/src/main/java/org/springframework/kafka/listener/ContainerProperties.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -311,6 +311,10 @@ public void setMessageListener(Object messageListener) {
311311
* Ignored when transactions are being used. Transactional consumers commit offsets
312312
* with semantics equivalent to {@code RECORD} or {@code BATCH}, depending on
313313
* the listener type.
314+
* However, setting it to {@code MANUAL} will provide access to an
315+
* {@code Acknowledgement} in the listener; when calling its
316+
* {@code nack(index, sleeptime)} method, the container will send the offsets of
317+
* the succcessfully processed records in the batch to the transaction.
314318
* @param ackMode the {@link AckMode}; default BATCH.
315319
* @see #setTransactionManager(PlatformTransactionManager)
316320
*/

src/reference/asciidoc/kafka.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1145,6 +1145,8 @@ Starting with version 2.3, the `Acknowledgment` interface has two additional met
11451145
The first one is used with a record listener, the second with a batch listener.
11461146
Calling the wrong method for your listener type will throw an `IllegalStateException`.
11471147

1148+
NOTE: If you want to commit a partial batch, using `nack()`, When using transactions, set the `AckMode` to `MANUAL`; invoking `nack()` will send the offsets of the successfully processed records to the transaction.
1149+
11481150
IMPORTANT: `nack()` can only be called on the consumer thread that invokes your listener.
11491151

11501152
With a record listener, when `nack()` is called, any pending offsets are committed, the remaing records from the last poll are discarded, and seeks are performed on their partitions so that the failed record and unprocessed records are redelivered on the next `poll()`.

0 commit comments

Comments
 (0)