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 TypeMethodDescriptiondefault String
Retrieve the group ID associated with this consumer seek callback, if available.void
Perform a seek operation.void
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
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
Perform a seek operation. When called fromConsumerSeekAware.onPartitionsAssigned(Map, ConsumerSeekCallback)
or fromConsumerSeekAware.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
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 fromConsumerSeekAware.onPartitionsAssigned(Map, ConsumerSeekCallback)
or fromConsumerSeekAware.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
Perform a seek to beginning operation. When called fromConsumerSeekAware.onPartitionsAssigned(Map, ConsumerSeekCallback)
or fromConsumerSeekAware.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
Perform a seek to beginning operation. When called fromConsumerSeekAware.onPartitionsAssigned(Map, ConsumerSeekCallback)
or fromConsumerSeekAware.onIdleContainer(Map, ConsumerSeekCallback)
perform the seek immediately on the consumer. When called from elsewhere, queue the seek operation to the consumer for eachTopicPartition
. The seek will occur after any pending offset commits. The consumer must be currently assigned the specified partition(s).- Parameters:
partitions
- theTopicPartition
s.- Since:
- 2.3.4
-
seekToEnd
Perform a seek to end operation. When called fromConsumerSeekAware.onPartitionsAssigned(Map, ConsumerSeekCallback)
or fromConsumerSeekAware.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
Perform a seek to end operation. When called fromConsumerSeekAware.onPartitionsAssigned(Map, ConsumerSeekCallback)
or fromConsumerSeekAware.onIdleContainer(Map, ConsumerSeekCallback)
perform the seek immediately on the consumer. When called from elsewhere, queue the seek operation to the consumer for eachTopicPartition
. The queued seek(s) will occur after any pending offset commits. The consumer must be currently assigned the specified partition(s).- Parameters:
partitions
- theTopicPartition
s.- Since:
- 2.3.4
-
seekRelative
Perform a seek relative to the start, end, or current position. When called fromConsumerSeekAware.onPartitionsAssigned(Map, ConsumerSeekCallback)
or fromConsumerSeekAware.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
Perform a seek to the first offset greater than or equal to the time stamp. When called fromConsumerSeekAware.onPartitionsAssigned(Map, ConsumerSeekCallback)
or fromConsumerSeekAware.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. UseseekToTimestamp(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 fromConsumerSeekAware.onPartitionsAssigned(Map, ConsumerSeekCallback)
or fromConsumerSeekAware.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
Retrieve the group ID associated with this consumer seek callback, if available. This method returnsnull
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
-