Interface ConsumerSeekAware

Functional Interface:
This is a functional interface and can therefore be used as the assignment target for a lambda expression or method reference.

@FunctionalInterface public interface ConsumerSeekAware
Interface for KafkaListener instances to implement if they wish to perform seek operations when the set of partitions assigned to the Consumer changes.

This callback interface is based on ConsumerRebalanceListener and it provides a KafkaSeeker object that can perform KafkaSeekOperation instances immediately.

Since:
4.1
See Also:
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    onPartitionsAssigned(@NonNull Collection<org.apache.kafka.common.TopicPartition> partitions, @NonNull KafkaSeeker seeker)
    A callback method the user can implement to provide handling of customized offsets on completion of a successful partition re-assignment.
    default void
    onPartitionsLost(@NonNull Collection<org.apache.kafka.common.TopicPartition> partitions)
     
    default void
    onPartitionsRevoked(@NonNull Collection<org.apache.kafka.common.TopicPartition> partitions)
     
  • Method Details

    • onPartitionsAssigned

      void onPartitionsAssigned(@NonNull @NonNull Collection<org.apache.kafka.common.TopicPartition> partitions, @NonNull @NonNull KafkaSeeker seeker)
      A callback method the user can implement to provide handling of customized offsets on completion of a successful partition re-assignment.

      This method will be called after the partition re-assignment completes and before the consumer starts fetching data, and only as the result of a poll(long) call. Under normal conditions, onPartitionsRevoked(Collection) will be executed before onPartitionsAssigned(Collection, KafkaSeeker).

      The provided KafkaSeeker object can perform seek operations on the underlying consumer.

      Parameters:
      partitions - The list of partitions that are now assigned to the consumer
      seeker - The object that can perform seek operations
      See Also:
      • ConsumerRebalanceListener.onPartitionsAssigned(Collection)
    • onPartitionsRevoked

      default void onPartitionsRevoked(@NonNull @NonNull Collection<org.apache.kafka.common.TopicPartition> partitions)
      Parameters:
      partitions - The list of partitions that were assigned to the consumer and now need to be revoked (may not include all currently assigned partitions, i.e. there may still be some partitions left)
      See Also:
      • ConsumerRebalanceListener.onPartitionsRevoked(Collection)
    • onPartitionsLost

      default void onPartitionsLost(@NonNull @NonNull Collection<org.apache.kafka.common.TopicPartition> partitions)
      Parameters:
      partitions - The list of partitions that are now assigned to the consumer (previously owned partitions will NOT be included, i.e. this list will only include newly added partitions)
      See Also:
      • ConsumerRebalanceListener.onPartitionsLost(Collection)