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)
    • Method Summary

      All Methods Instance Methods Abstract Methods Default Methods 
      Modifier and Type Method Description
      void acknowledge()
      Invoked when the record or batch for which the acknowledgment has been created has been processed.
      default void nack​(int index, long sleepMillis)
      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 time (in milliseconds).
      default void nack​(long sleepMillis)
      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 time (in milliseconds).
    • Method Detail

      • 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​(long sleepMillis)
        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 time (in milliseconds). Must be called on the consumer thread.

        Parameters:
        sleepMillis - the time to sleep in milliseconds; the actual sleep time will be larger of this value and the container's maxPollInterval, which defaults to 5 seconds.
        Since:
        2.3
      • nack

        default void nack​(int index,
                          long sleepMillis)
        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 time (in milliseconds). Must be called on the consumer thread.

        Parameters:
        index - the index of the failed record in the batch.
        sleepMillis - the time to sleep in milliseconds; the actual sleep time will be larger of this value and the container's maxPollInterval, which defaults to 5 seconds.
        Since:
        2.3