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 Type
    Method
    Description
    void
    Invoked when the record or batch for which the acknowledgment has been created has been processed.
    default void
    nack(int index, Duration sleep)
    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
    nack(Duration sleep)
    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

      default void nack(Duration sleep)
      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's maxPollInterval, which defaults to 5 seconds.
      Since:
      2.8.7
    • nack

      default void nack(int index, Duration sleep)
      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's maxPollInterval, which defaults to 5 seconds.
      Since:
      2.8.7