Interface ConsumerSeekAware
- All Known Implementing Classes:
AbstractConsumerSeekAware
,AbstractDelegatingMessageListenerAdapter
,AbstractFilteringMessageListener
,AbstractRetryingMessageListenerAdapter
,AggregatingReplyingKafkaTemplate
,BatchMessagingMessageListenerAdapter
,FilteringBatchMessageListenerAdapter
,FilteringMessageListenerAdapter
,KafkaBackoffAwareMessageListenerAdapter
,MessagingMessageListenerAdapter
,RecordMessagingMessageListenerAdapter
,ReplyingKafkaTemplate
public interface ConsumerSeekAware
Listeners that implement this interface are provided with a
ConsumerSeekAware.ConsumerSeekCallback
which can be used to perform a
seek operation.- Since:
- 1.1
- Author:
- Gary Russell
-
Nested Class Summary
Modifier and TypeInterfaceDescriptionstatic interface
A callback that a listener can invoke to seek to a specific offset. -
Method Summary
Modifier and TypeMethodDescriptiondefault void
When using manual partition assignment, called when the first poll has completed; useful when usingauto.offset.reset=latest
and you need to wait until the initial position has been established.default void
onIdleContainer
(Map<org.apache.kafka.common.TopicPartition, Long> assignments, ConsumerSeekAware.ConsumerSeekCallback callback) If the container is configured to emit idle container events, this method is called when the container idle event is emitted - allowing a seek operation.default void
onPartitionsAssigned
(Map<org.apache.kafka.common.TopicPartition, Long> assignments, ConsumerSeekAware.ConsumerSeekCallback callback) When using group management, called when partition assignments change.default void
onPartitionsRevoked
(Collection<org.apache.kafka.common.TopicPartition> partitions) When using group management, called when partition assignments are revoked.default void
Register the callback to use when seeking at some arbitrary time.default void
Called when the listener consumer terminates allowing implementations to clean up state, such as thread locals.
-
Method Details
-
registerSeekCallback
Register the callback to use when seeking at some arbitrary time. When used with aConcurrentMessageListenerContainer
or the same listener instance in multiple containers listeners should store the callback in aThreadLocal
.- Parameters:
callback
- the callback.
-
onPartitionsAssigned
default void onPartitionsAssigned(Map<org.apache.kafka.common.TopicPartition, Long> assignments, ConsumerSeekAware.ConsumerSeekCallback callback) When using group management, called when partition assignments change.- Parameters:
assignments
- the new assignments and their current offsets.callback
- the callback to perform an initial seek after assignment.
-
onPartitionsRevoked
When using group management, called when partition assignments are revoked. Listeners should discard any callback saved fromregisterSeekCallback(ConsumerSeekCallback)
on this thread.- Parameters:
partitions
- the partitions that have been revoked.- Since:
- 2.3
-
onIdleContainer
default void onIdleContainer(Map<org.apache.kafka.common.TopicPartition, Long> assignments, ConsumerSeekAware.ConsumerSeekCallback callback) If the container is configured to emit idle container events, this method is called when the container idle event is emitted - allowing a seek operation.- Parameters:
assignments
- the new assignments and their current offsets.callback
- the callback to perform a seek.
-
onFirstPoll
default void onFirstPoll()When using manual partition assignment, called when the first poll has completed; useful when usingauto.offset.reset=latest
and you need to wait until the initial position has been established.- Since:
- 2.8.8
-
unregisterSeekCallback
default void unregisterSeekCallback()Called when the listener consumer terminates allowing implementations to clean up state, such as thread locals.- Since:
- 2.4
-