Interface Acknowledgment
public interface Acknowledgment
Handle for acknowledging the processing of a
ConsumerRecord
. Recipients can store the
reference in asynchronous scenarios, but the internal state should be assumed transient
(i.e. it cannot be serialized and deserialized later)- Author:
- Marius Bogoevici, Gary Russell
-
Method Summary
Modifier and TypeMethodDescriptionvoid
Invoked when the record or batch for which the acknowledgment has been created has been processed.default void
acknowledge
(int index) Acknowledge the record at an index in the batch - commit the offset(s) of records in the batch up to and including the index.default void
Negatively acknowledge the record at an index in a batch - commit the offset(s) of records before the index and re-seek the partitions so that the record at the index and subsequent records will be redelivered after the sleep duration.default void
Negatively acknowledge the current record - discard remaining records from the poll and re-seek all partitions so that this record will be redelivered after the sleep duration.
-
Method Details
-
acknowledge
void acknowledge()Invoked when the record or batch for which the acknowledgment has been created has been processed. Calling this method implies that all the previous messages in the partition have been processed already. -
nack
Negatively acknowledge the current record - discard remaining records from the poll and re-seek all partitions so that this record will be redelivered after the sleep duration. Must be called on the consumer thread.- Parameters:
sleep
- the duration to sleep; the actual sleep time will be larger of this value and the container'smaxPollInterval
, which defaults to 5 seconds.- Since:
- 2.8.7
-
acknowledge
default void acknowledge(int index) Acknowledge the record at an index in the batch - commit the offset(s) of records in the batch up to and including the index. RequiresContainerProperties.AckMode.MANUAL_IMMEDIATE
. The index must be greater than any previous partial batch acknowledgment index for this batch and in the range of the record list. This method must be called on the listener thread.- Parameters:
index
- the index of the record to acknowledge.- Since:
- 3.0.10
-
nack
Negatively acknowledge the record at an index in a batch - commit the offset(s) of records before the index and re-seek the partitions so that the record at the index and subsequent records will be redelivered after the sleep duration. Must be called on the consumer thread.- Parameters:
index
- the index of the failed record in the batch.sleep
- the duration to sleep; the actual sleep time will be larger of this value and the container'smaxPollInterval
, which defaults to 5 seconds.- Since:
- 2.8.7
-