bbejeck commented on code in PR #20528:
URL: https://github.com/apache/kafka/pull/20528#discussion_r2344663831
##########
clients/src/main/java/org/apache/kafka/clients/consumer/ConsumerRebalanceListener.java:
##########
@@ -120,13 +120,31 @@ public interface ConsumerRebalanceListener {
/**
* A callback method the user can implement to provide handling of offset
commits to a customized store.
* This method will be called during a rebalance operation when the
consumer has to give up some partitions.
- * It can also be called when consumer is being closed ({@link
KafkaConsumer#close(CloseOptions option)})
- * or is unsubscribing ({@link KafkaConsumer#unsubscribe()}).
+ * The consumer may need to give up some partitions (thus this callback
executed) under the following scenarios:
+ * <ul>
+ * <li>If the consumer assignment changes</li>
+ * <li>If the consumer is being closed ({@link
KafkaConsumer#close(CloseOptions option)})</li>
+ * <li>If the consumer is unsubscribing ({@link
KafkaConsumer#unsubscribe()})</li>
+ * </ul>
* It is recommended that offsets should be committed in this callback to
either Kafka or a
* custom offset store to prevent duplicate data.
* <p>
- * In eager rebalancing, it will always be called at the start of a
rebalance and after the consumer stops fetching data.
- * In cooperative rebalancing, it will be called at the end of a rebalance
on the set of partitions being revoked iff the set is non-empty.
+ * This callback is always called before re-assigning the partitions.
+ * If the consumer is using the {@link GroupProtocol#CLASSIC} rebalance
protocol:
+ * <ul>
+ * <li>
+ * In eager rebalancing, onPartitionsRevoked will be called with
the full set of assigned partitions as parameter (all partitions are revoked).
Review Comment:
```suggestion
* In eager rebalancing, onPartitionsRevoked will be called with
the full set of assigned partitions as a parameter (all partitions are revoked).
```
##########
clients/src/main/java/org/apache/kafka/clients/consumer/ConsumerRebalanceListener.java:
##########
@@ -120,13 +120,31 @@ public interface ConsumerRebalanceListener {
/**
* A callback method the user can implement to provide handling of offset
commits to a customized store.
* This method will be called during a rebalance operation when the
consumer has to give up some partitions.
- * It can also be called when consumer is being closed ({@link
KafkaConsumer#close(CloseOptions option)})
- * or is unsubscribing ({@link KafkaConsumer#unsubscribe()}).
+ * The consumer may need to give up some partitions (thus this callback
executed) under the following scenarios:
+ * <ul>
+ * <li>If the consumer assignment changes</li>
+ * <li>If the consumer is being closed ({@link
KafkaConsumer#close(CloseOptions option)})</li>
+ * <li>If the consumer is unsubscribing ({@link
KafkaConsumer#unsubscribe()})</li>
+ * </ul>
* It is recommended that offsets should be committed in this callback to
either Kafka or a
* custom offset store to prevent duplicate data.
* <p>
- * In eager rebalancing, it will always be called at the start of a
rebalance and after the consumer stops fetching data.
- * In cooperative rebalancing, it will be called at the end of a rebalance
on the set of partitions being revoked iff the set is non-empty.
+ * This callback is always called before re-assigning the partitions.
+ * If the consumer is using the {@link GroupProtocol#CLASSIC} rebalance
protocol:
+ * <ul>
+ * <li>
+ * In eager rebalancing, onPartitionsRevoked will be called with
the full set of assigned partitions as parameter (all partitions are revoked).
+ * It will be called even if there are no partitions to revoke.
+ * </li>
+ * <li>
+ * In cooperative rebalancing, onPartitionsRevoked will be called
with the set of partitions to revoked,
Review Comment:
```suggestion
* In cooperative rebalancing, onPartitionsRevoked will be
called with the set of partitions to revoke
```
##########
clients/src/main/java/org/apache/kafka/clients/consumer/ConsumerRebalanceListener.java:
##########
@@ -120,13 +120,31 @@ public interface ConsumerRebalanceListener {
/**
* A callback method the user can implement to provide handling of offset
commits to a customized store.
* This method will be called during a rebalance operation when the
consumer has to give up some partitions.
- * It can also be called when consumer is being closed ({@link
KafkaConsumer#close(CloseOptions option)})
- * or is unsubscribing ({@link KafkaConsumer#unsubscribe()}).
+ * The consumer may need to give up some partitions (thus this callback
executed) under the following scenarios:
+ * <ul>
+ * <li>If the consumer assignment changes</li>
+ * <li>If the consumer is being closed ({@link
KafkaConsumer#close(CloseOptions option)})</li>
+ * <li>If the consumer is unsubscribing ({@link
KafkaConsumer#unsubscribe()})</li>
+ * </ul>
* It is recommended that offsets should be committed in this callback to
either Kafka or a
* custom offset store to prevent duplicate data.
* <p>
- * In eager rebalancing, it will always be called at the start of a
rebalance and after the consumer stops fetching data.
- * In cooperative rebalancing, it will be called at the end of a rebalance
on the set of partitions being revoked iff the set is non-empty.
+ * This callback is always called before re-assigning the partitions.
+ * If the consumer is using the {@link GroupProtocol#CLASSIC} rebalance
protocol:
+ * <ul>
+ * <li>
+ * In eager rebalancing, onPartitionsRevoked will be called with
the full set of assigned partitions as parameter (all partitions are revoked).
+ * It will be called even if there are no partitions to revoke.
+ * </li>
+ * <li>
+ * In cooperative rebalancing, onPartitionsRevoked will be called
with the set of partitions to revoked,
+ * iff the set is non-empty.
+ * </li>
+ * </ul>
+ * If the consumer is using the {@link GroupProtocol#CONSUMER} rebalance
protocol, this callback will be called
+ * with the set of partitions to revoked iff the set is non-empty
Review Comment:
```suggestion
* with the set of partitions to be revoked iff the set is non-empty
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]