Skip to content

Commit 1082614

Browse files
authored
Improve docs about Acknowledgment.nack() (#2906)
1 parent 772d0ae commit 1082614

File tree

2 files changed

+5
-1
lines changed

2 files changed

+5
-1
lines changed

spring-kafka-docs/src/main/antora/modules/ROOT/pages/kafka/receiving-messages/message-listener-container.adoc

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,8 @@ With a record listener, when `nack()` is called, any pending offsets are committ
233233
The consumer can be paused before redelivery, by setting the `sleep` argument.
234234
This is similar functionality to throwing an exception when the container is configured with a `DefaultErrorHandler`.
235235

236+
IMPORTANT: `nack()` pauses the entire listener for the specified sleep duration including all assigned partitions.
237+
236238
When using a batch listener, you can specify the index within the batch where the failure occurred.
237239
When `nack()` is called, offsets will be committed for records before the index and seeks are performed on the partitions for the failed and discarded records so that they will be redelivered on the next `poll()`.
238240

spring-kafka/src/main/java/org/springframework/kafka/support/Acknowledgment.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,9 @@ public interface Acknowledgment {
4141
/**
4242
* Negatively acknowledge the current record - discard remaining records from the poll
4343
* and re-seek all partitions so that this record will be redelivered after the sleep
44-
* duration. Must be called on the consumer thread.
44+
* duration. This will pause reading for the entire message listener for the specified
45+
* sleep duration and is not limited to a single partition.
46+
* Must be called on the consumer thread.
4547
* <p>
4648
* @param sleep the duration to sleep; the actual sleep time will be larger of this value
4749
* and the container's {@code maxPollInterval}, which defaults to 5 seconds.

0 commit comments

Comments
 (0)