ConsumerRebalanceListener

ConsumerRebalanceListener is a callback interface to be notified when the set of partitions assigned to the consumer (aka assignment) changes.

ConsumerRebalanceListener is notified about the newly-assigned partitions through onPartitionsAssigned callback that happens when ConsumerCoordinator is requested to onJoinComplete.

ConsumerRebalanceListener is notified about the partitions revoked through onPartitionsRevoked callback that happens when ConsumerCoordinator is requested to onJoinPrepare.

Caution
FIXME Picture when the notifications are triggered
package org.apache.kafka.clients.consumer;

interface ConsumerRebalanceListener {
  void onPartitionsAssigned(Collection<TopicPartition> partitions);
  void onPartitionsRevoked(Collection<TopicPartition> partitions);
}

ConsumerRebalanceListener is used when a Kafka Consumer is requested to subscribe to topics.

void subscribe(Collection<String> topics, ConsumerRebalanceListener callback);
void subscribe(Pattern pattern, ConsumerRebalanceListener callback);
Table 1. ConsumerRebalanceListener Contract
Method Description

onPartitionsAssigned

Used exclusively when ConsumerCoordinator is requested to onJoinComplete

onPartitionsRevoked

Used exclusively when ConsumerCoordinator is requested to onJoinPrepare

results matching ""

    No results matching ""