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:
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic enumDetermines the interpretation of theoffset()value. -
Method Summary
Modifier and TypeMethodDescriptionlongoffset()@NonNull KafkaSeekOperation.OffsetTypedefault intstatic @NonNull KafkaSeekOperationseek(@NonNull TopicPartition topicPartition, long offset) Creates an absolute seek operation.static @NonNull KafkaSeekOperationseekBackward(@NonNull TopicPartition topicPartition, long offset) Creates a backward seek operation.static @NonNull KafkaSeekOperationseekForward(@NonNull TopicPartition topicPartition, long offset) Creates a forward seek operation.static @NonNull KafkaSeekOperationseekRelativeToBeginning(@NonNull TopicPartition topicPartition, long offset) Creates a seek operation relative to the beginning.static @NonNull KafkaSeekOperationseekRelativeToEnd(@NonNull TopicPartition topicPartition, long offset) Creates a seek operation relative to the end.static @NonNull List<KafkaSeekOperation>seekToBeginning(@NonNull Collection<TopicPartition> partitions) Creates a list of seek to the beginning operations.static @NonNull KafkaSeekOperationseekToBeginning(@NonNull TopicPartition topicPartition) Creates a seek to the beginning operation.static @NonNull List<KafkaSeekOperation>seekToEnd(@NonNull Collection<TopicPartition> partitions) Creates a list of seek to the end operations.static @NonNull KafkaSeekOperationseekToEnd(@NonNull TopicPartition topicPartition) Creates a seek to the end operation.static @NonNull List<KafkaSeekOperation>seekToTimestamp(@NonNull Collection<TopicPartition> topicPartitions, long timestamp) Creates a list of seek to the timestamp operations.static @NonNull KafkaSeekOperationseekToTimestamp(@NonNull TopicPartition topicPartition, long timestamp) Creates a seek to the timestamp operation.default @NonNull Stringtopic()@NonNull TopicPartition
-
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- theTopicPartitions.- 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- theTopicPartitions.- 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
- Returns:
- the topic name and partition number on which the seek should be performed.
-
offsetType
- Returns:
- the offset type.
-
offset
long offset()- Returns:
- the offset that should be used to perform the seek. Must be positive.
-
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.
-