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 
      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 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 time.
      default void nack​(long 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 time.
    • 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 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 time. Must be called on the consumer thread.

        When using group management, sleep + time spent processing the previous messages from the poll must be less than the consumer max.poll.interval.ms property, to avoid a rebalance.

        Parameters:
        sleep - the time to sleep; 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 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 time. Must be called on the consumer thread.

        When using group management, sleep + time spent processing the records before the index must be less than the consumer max.poll.interval.ms property, to avoid a rebalance.

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