Interface ConsumerSeekAware.ConsumerSeekCallback

Enclosing interface:
ConsumerSeekAware

public static interface ConsumerSeekAware.ConsumerSeekCallback
A callback that a listener can invoke to seek to a specific offset.
  • Method Summary

    Modifier and Type
    Method
    Description
    default String
    Retrieve the group ID associated with this consumer seek callback, if available.
    void
    seek(String topic, int partition, long offset)
    Perform a seek operation.
    void
    seek(String topic, int partition, Function<Long,Long> offsetComputeFunction)
    Perform a seek operation based on the given function to compute the offset to seek to.
    void
    seekRelative(String topic, int partition, long offset, boolean toCurrent)
    Perform a seek relative to the start, end, or current position.
    void
    seekToBeginning(String topic, int partition)
    Perform a seek to beginning operation.
    default void
    seekToBeginning(Collection<org.apache.kafka.common.TopicPartition> partitions)
    Perform a seek to beginning operation.
    void
    seekToEnd(String topic, int partition)
    Perform a seek to end operation.
    default void
    seekToEnd(Collection<org.apache.kafka.common.TopicPartition> partitions)
    Perform a seek to end operation.
    void
    seekToTimestamp(String topic, int partition, long timestamp)
    Perform a seek to the first offset greater than or equal to the time stamp.
    void
    seekToTimestamp(Collection<org.apache.kafka.common.TopicPartition> topicPartitions, long timestamp)
    Perform a seek to the first offset greater than or equal to the time stamp.
  • Method Details

    • seek

      void seek(String topic, int partition, long offset)
      Perform a seek operation. When called from ConsumerSeekAware.onPartitionsAssigned(Map, ConsumerSeekCallback) or from ConsumerSeekAware.onIdleContainer(Map, ConsumerSeekCallback) perform the seek immediately on the consumer. When called from elsewhere, queue the seek operation to the consumer. The queued seek will occur after any pending offset commits. The consumer must be currently assigned the specified partition.
      Parameters:
      topic - the topic.
      partition - the partition.
      offset - the offset (absolute).
    • seek

      void seek(String topic, int partition, Function<Long,Long> offsetComputeFunction)
      Perform a seek operation based on the given function to compute the offset to seek to. The function provides the user with access to the current offset in the consumer which is the current position, i.e, the next offset to be fetched. When called from ConsumerSeekAware.onPartitionsAssigned(Map, ConsumerSeekCallback) or from ConsumerSeekAware.onIdleContainer(Map, ConsumerSeekCallback) perform the seek immediately on the consumer. When called from elsewhere, queue the seek operation to the consumer. The queued seek will occur after any pending offset commits. The consumer must be currently assigned the specified partition.
      Parameters:
      topic - the topic.
      partition - the partition.
      offsetComputeFunction - function to compute the absolute offset to seek to.
      Since:
      3.2.0
    • seekToBeginning

      void seekToBeginning(String topic, int partition)
      Perform a seek to beginning operation. When called from ConsumerSeekAware.onPartitionsAssigned(Map, ConsumerSeekCallback) or from ConsumerSeekAware.onIdleContainer(Map, ConsumerSeekCallback) perform the seek immediately on the consumer. When called from elsewhere, queue the seek operation to the consumer. The queued seek will occur after any pending offset commits. The consumer must be currently assigned the specified partition.
      Parameters:
      topic - the topic.
      partition - the partition.
    • seekToBeginning

      default void seekToBeginning(Collection<org.apache.kafka.common.TopicPartition> partitions)
      Perform a seek to beginning operation. When called from ConsumerSeekAware.onPartitionsAssigned(Map, ConsumerSeekCallback) or from ConsumerSeekAware.onIdleContainer(Map, ConsumerSeekCallback) perform the seek immediately on the consumer. When called from elsewhere, queue the seek operation to the consumer for each TopicPartition. The seek will occur after any pending offset commits. The consumer must be currently assigned the specified partition(s).
      Parameters:
      partitions - the TopicPartitions.
      Since:
      2.3.4
    • seekToEnd

      void seekToEnd(String topic, int partition)
      Perform a seek to end operation. When called from ConsumerSeekAware.onPartitionsAssigned(Map, ConsumerSeekCallback) or from ConsumerSeekAware.onIdleContainer(Map, ConsumerSeekCallback) perform the seek immediately on the consumer. When called from elsewhere, queue the seek operation to the consumer. The queued seek will occur after any pending offset commits. The consumer must be currently assigned the specified partition.
      Parameters:
      topic - the topic.
      partition - the partition.
    • seekToEnd

      default void seekToEnd(Collection<org.apache.kafka.common.TopicPartition> partitions)
      Perform a seek to end operation. When called from ConsumerSeekAware.onPartitionsAssigned(Map, ConsumerSeekCallback) or from ConsumerSeekAware.onIdleContainer(Map, ConsumerSeekCallback) perform the seek immediately on the consumer. When called from elsewhere, queue the seek operation to the consumer for each TopicPartition. The queued seek(s) will occur after any pending offset commits. The consumer must be currently assigned the specified partition(s).
      Parameters:
      partitions - the TopicPartitions.
      Since:
      2.3.4
    • seekRelative

      void seekRelative(String topic, int partition, long offset, boolean toCurrent)
      Perform a seek relative to the start, end, or current position. When called from ConsumerSeekAware.onPartitionsAssigned(Map, ConsumerSeekCallback) or from ConsumerSeekAware.onIdleContainer(Map, ConsumerSeekCallback) perform the seek immediately on the consumer. When called from elsewhere, queue the seek operation. The queued seek will occur after any pending offset commits. The consumer must be currently assigned the specified partition.
      Parameters:
      topic - the topic.
      partition - the partition.
      offset - the offset; positive values are relative to the start, negative values are relative to the end, unless toCurrent is true.
      toCurrent - true for the offset to be relative to the current position rather than the beginning or end.
      Since:
      2.3
    • seekToTimestamp

      void seekToTimestamp(String topic, int partition, long timestamp)
      Perform a seek to the first offset greater than or equal to the time stamp. When called from ConsumerSeekAware.onPartitionsAssigned(Map, ConsumerSeekCallback) or from ConsumerSeekAware.onIdleContainer(Map, ConsumerSeekCallback) perform the seek immediately on the consumer. When called from elsewhere, queue the seek operation. The queued seek will occur after any pending offset commits. The consumer must be currently assigned the specified partition. Use seekToTimestamp(Collection, long) when seeking multiple partitions because the offset lookup is blocking.
      Parameters:
      topic - the topic.
      partition - the partition.
      timestamp - the time stamp.
      Since:
      2.3
      See Also:
    • seekToTimestamp

      void seekToTimestamp(Collection<org.apache.kafka.common.TopicPartition> topicPartitions, long timestamp)
      Perform a seek to the first offset greater than or equal to the time stamp. When called from ConsumerSeekAware.onPartitionsAssigned(Map, ConsumerSeekCallback) or from ConsumerSeekAware.onIdleContainer(Map, ConsumerSeekCallback) perform the seek immediately on the consumer. When called from elsewhere, queue the seek operation. The queued seek will occur after any pending offset commits. The consumer must be currently assigned the specified partition.
      Parameters:
      topicPartitions - the topic/partitions.
      timestamp - the time stamp.
      Since:
      2.3
    • getGroupId

      @Nullable default String getGroupId()
      Retrieve the group ID associated with this consumer seek callback, if available. This method returns null by default, indicating that the group ID is not specified. Implementations may override this method to provide a specific group ID value.
      Returns:
      the consumer group ID.
      Since:
      3.3