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

      All Methods Instance Methods Abstract Methods Default Methods Deprecated 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)
      Deprecated.
      default void nack​(int index, java.time.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​(long sleepMillis)
      Deprecated.
      in favor of nack(Duration)
      default void nack​(java.time.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 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

        @Deprecated
        default void nack​(long sleepMillis)
        Deprecated.
        in favor of nack(Duration)
        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​(java.time.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

        @Deprecated
        default void nack​(int index,
                          long sleepMillis)
        Deprecated.
        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
      • nack

        default void nack​(int index,
                          java.time.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