public abstract class AbstractConsumerSeekAware extends java.lang.Object implements ConsumerSeekAware
ConsumerSeekAware.ConsumerSeekCallback
s for the listener. If the
listener subclasses this class, it can easily seek arbitrary topics/partitions without
having to keep track of the callbacks itself.ConsumerSeekAware.ConsumerSeekCallback
Constructor and Description |
---|
AbstractConsumerSeekAware() |
Modifier and Type | Method and Description |
---|---|
protected ConsumerSeekAware.ConsumerSeekCallback |
getSeekCallbackFor(org.apache.kafka.common.TopicPartition topicPartition)
Return the callback for the specified topic/partition.
|
protected java.util.Map<org.apache.kafka.common.TopicPartition,ConsumerSeekAware.ConsumerSeekCallback> |
getSeekCallbacks()
The map of callbacks for all currently assigned partitions.
|
void |
onPartitionsAssigned(java.util.Map<org.apache.kafka.common.TopicPartition,java.lang.Long> assignments,
ConsumerSeekAware.ConsumerSeekCallback callback)
When using group management, called when partition assignments change.
|
void |
onPartitionsRevoked(java.util.Collection<org.apache.kafka.common.TopicPartition> partitions)
When using group management, called when partition assignments are revoked.
|
void |
registerSeekCallback(ConsumerSeekAware.ConsumerSeekCallback callback)
Register the callback to use when seeking at some arbitrary time.
|
void |
unregisterSeekCallback()
Called when the listener consumer terminates allowing implementations to clean up
state, such as thread locals.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
onIdleContainer
public void registerSeekCallback(ConsumerSeekAware.ConsumerSeekCallback callback)
ConsumerSeekAware
ConcurrentMessageListenerContainer
or the same listener instance in multiple
containers listeners should store the callback in a ThreadLocal
.registerSeekCallback
in interface ConsumerSeekAware
callback
- the callback.public void onPartitionsAssigned(java.util.Map<org.apache.kafka.common.TopicPartition,java.lang.Long> assignments, ConsumerSeekAware.ConsumerSeekCallback callback)
ConsumerSeekAware
onPartitionsAssigned
in interface ConsumerSeekAware
assignments
- the new assignments and their current offsets.callback
- the callback to perform an initial seek after assignment.public void onPartitionsRevoked(java.util.Collection<org.apache.kafka.common.TopicPartition> partitions)
ConsumerSeekAware
ConsumerSeekAware.registerSeekCallback(ConsumerSeekCallback)
on this thread.onPartitionsRevoked
in interface ConsumerSeekAware
partitions
- the partitions that have been revoked.public void unregisterSeekCallback()
ConsumerSeekAware
unregisterSeekCallback
in interface ConsumerSeekAware
@Nullable protected ConsumerSeekAware.ConsumerSeekCallback getSeekCallbackFor(org.apache.kafka.common.TopicPartition topicPartition)
topicPartition
- the topic/partition.protected java.util.Map<org.apache.kafka.common.TopicPartition,ConsumerSeekAware.ConsumerSeekCallback> getSeekCallbacks()