Interface KafkaBindingRebalanceListener


public interface KafkaBindingRebalanceListener
A rebalance listener that provides access to the binding name consumer object. It can be used to perform seek operations on the consumer after a rebalance.
Since:
2.1
Author:
Gary Russell
  • Method Summary

    Modifier and Type
    Method
    Description
    default void
    onPartitionsAssigned(String bindingName, org.apache.kafka.clients.consumer.Consumer<?,?> consumer, Collection<org.apache.kafka.common.TopicPartition> partitions, boolean initial)
    Invoked when partitions are initially assigned or after a rebalance.
    default void
    onPartitionsRevokedAfterCommit(String bindingName, org.apache.kafka.clients.consumer.Consumer<?,?> consumer, Collection<org.apache.kafka.common.TopicPartition> partitions)
    Invoked by the container after any pending offsets are committed.
    default void
    onPartitionsRevokedBeforeCommit(String bindingName, org.apache.kafka.clients.consumer.Consumer<?,?> consumer, Collection<org.apache.kafka.common.TopicPartition> partitions)
    Invoked by the container before any pending offsets are committed.
  • Method Details

    • onPartitionsRevokedBeforeCommit

      default void onPartitionsRevokedBeforeCommit(String bindingName, org.apache.kafka.clients.consumer.Consumer<?,?> consumer, Collection<org.apache.kafka.common.TopicPartition> partitions)
      Invoked by the container before any pending offsets are committed.
      Parameters:
      bindingName - the name of the binding.
      consumer - the consumer.
      partitions - the partitions.
    • onPartitionsRevokedAfterCommit

      default void onPartitionsRevokedAfterCommit(String bindingName, org.apache.kafka.clients.consumer.Consumer<?,?> consumer, Collection<org.apache.kafka.common.TopicPartition> partitions)
      Invoked by the container after any pending offsets are committed.
      Parameters:
      bindingName - the name of the binding.
      consumer - the consumer.
      partitions - the partitions.
    • onPartitionsAssigned

      default void onPartitionsAssigned(String bindingName, org.apache.kafka.clients.consumer.Consumer<?,?> consumer, Collection<org.apache.kafka.common.TopicPartition> partitions, boolean initial)
      Invoked when partitions are initially assigned or after a rebalance. Applications might only want to perform seek operations on an initial assignment. While the 'initial' argument is true for each thread (when concurrency is greater than 1), implementations should keep track of exactly which partitions have been sought. There is a race in that a rebalance could occur during startup and so a topic/ partition that has been sought on one thread may be re-assigned to another thread and you may not wish to re-seek it at that time.
      Parameters:
      bindingName - the name of the binding.
      consumer - the consumer.
      partitions - the partitions.
      initial - true if this is the initial assignment on the current thread.