Interface KafkaSeekOperation


public interface KafkaSeekOperation
Represents a seek operation that may be performed on a Consumer.

If successful, the operation will determine the next offset returned by Consumer.poll(Duration).

Since:
4.1
Author:
Guillermo Calvo
See Also:
  • Method Details

    • seek

      @NonNull static @NonNull KafkaSeekOperation seek(@NonNull @NonNull TopicPartition topicPartition, long offset)
      Creates an absolute seek operation.
      Parameters:
      topicPartition - the topic partition.
      offset - the absolute offset. Must be zero or greater.
      Returns:
      an absolute seek operation.
    • seekRelativeToBeginning

      @NonNull static @NonNull KafkaSeekOperation seekRelativeToBeginning(@NonNull @NonNull TopicPartition topicPartition, long offset)
      Creates a seek operation relative to the beginning.
      Parameters:
      topicPartition - the topic partition.
      offset - the offset. Must be zero or greater.
      Returns:
      a seek operation relative to the beginning.
    • seekToBeginning

      @NonNull static @NonNull KafkaSeekOperation seekToBeginning(@NonNull @NonNull TopicPartition topicPartition)
      Creates a seek to the beginning operation.
      Parameters:
      topicPartition - the topic partition.
      Returns:
      a seek to the beginning operation.
    • seekToBeginning

      @NonNull static @NonNull List<KafkaSeekOperation> seekToBeginning(@NonNull @NonNull Collection<TopicPartition> partitions)
      Creates a list of seek to the beginning operations.
      Parameters:
      partitions - the TopicPartitions.
      Returns:
      a list of seek to the beginning operations.
    • seekRelativeToEnd

      @NonNull static @NonNull KafkaSeekOperation seekRelativeToEnd(@NonNull @NonNull TopicPartition topicPartition, long offset)
      Creates a seek operation relative to the end.
      Parameters:
      topicPartition - the topic partition.
      offset - the offset. Must be zero or greater.
      Returns:
      a seek operation relative to the end.
    • seekToEnd

      @NonNull static @NonNull KafkaSeekOperation seekToEnd(@NonNull @NonNull TopicPartition topicPartition)
      Creates a seek to the end operation.
      Parameters:
      topicPartition - the topic partition.
      Returns:
      a seek to the end operation.
    • seekToEnd

      @NonNull static @NonNull List<KafkaSeekOperation> seekToEnd(@NonNull @NonNull Collection<TopicPartition> partitions)
      Creates a list of seek to the end operations.
      Parameters:
      partitions - the TopicPartitions.
      Returns:
      a list of seek to the end operations.
    • seekForward

      @NonNull static @NonNull KafkaSeekOperation seekForward(@NonNull @NonNull TopicPartition topicPartition, long offset)
      Creates a forward seek operation.
      Parameters:
      topicPartition - the topic partition.
      offset - the offset. Must be zero or greater.
      Returns:
      a forward seek operation.
    • seekBackward

      @NonNull static @NonNull KafkaSeekOperation seekBackward(@NonNull @NonNull TopicPartition topicPartition, long offset)
      Creates a backward seek operation.
      Parameters:
      topicPartition - the topic partition.
      offset - the offset. Must be zero or greater.
      Returns:
      a backward seek operation.
    • seekToTimestamp

      @NonNull static @NonNull KafkaSeekOperation seekToTimestamp(@NonNull @NonNull TopicPartition topicPartition, long timestamp)
      Creates a seek to the timestamp operation.

      This operation will seek to the first offset whose timestamp is greater than or equal to the given one if it exists; otherwise it will seek to the end.

      Parameters:
      topicPartition - the topic partition.
      timestamp - the kafka time stamp.
      Returns:
      a seek to the timestamp operation.
    • seekToTimestamp

      @NonNull static @NonNull List<KafkaSeekOperation> seekToTimestamp(@NonNull @NonNull Collection<TopicPartition> topicPartitions, long timestamp)
      Creates a list of seek to the timestamp operations.

      This operation will seek to the first offset whose timestamp is greater than or equal to the given one if it exists; otherwise it will seek to the end.

      Parameters:
      topicPartitions - the topic/partitions.
      timestamp - the kafka time stamp.
      Returns:
      a list of seek to the timestamp operations.
    • topicPartition

      @NonNull @NonNull TopicPartition topicPartition()
      Returns:
      the topic name and partition number on which the seek should be performed.
    • offsetType

      @NonNull @NonNull KafkaSeekOperation.OffsetType offsetType()
      Returns:
      the offset type.
    • offset

      long offset()
      Returns:
      the offset that should be used to perform the seek. Must be positive.
    • topic

      @NonNull default @NonNull String topic()
      Returns:
      the topic name on which the seek will be performed.
    • partition

      default int partition()
      Returns:
      the partition number on which the seek will be performed.