lianetm commented on code in PR #14385:
URL: https://github.com/apache/kafka/pull/14385#discussion_r1327771100


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/PrototypeAsyncConsumer.java:
##########
@@ -667,6 +683,35 @@ private static <K, V> ClusterResourceListeners 
configureClusterResourceListeners
         return clusterResourceListeners;
     }
 
+    /**
+     *
+     * Indicates if the consumer is using the Kafka-based offset management 
strategy,
+     * according to config {@link CommonClientConfigs#GROUP_ID_CONFIG}
+     */
+    private boolean isCommittedOffsetsManagementEnabled() {
+        return groupId.isPresent();
+    }
+
+    /**
+     * Refresh the committed offsets for provided partitions.
+     *
+     * @param timer Timer bounding how long this method can block
+     * @return true iff the operation completed within the timeout
+     */
+    private boolean refreshCommittedOffsetsIfNeeded(Timer timer) {
+        final Set<TopicPartition> initializingPartitions = 
subscriptions.initializingPartitions();
+
+        log.debug("Refreshing committed offsets for partitions {}", 
initializingPartitions);
+        try {
+            final Map<TopicPartition, OffsetAndMetadata> offsets = 
eventHandler.addAndGet(new OffsetFetchApplicationEvent(initializingPartitions), 
timer);

Review Comment:
   You described it correctly, but yes, that's how the existing consumer does 
it so we wanted to ensure the same behaviour. When initializing positions:
   - if using committed offsets, the current consumer blocks on 
[fetchCommittedOffsets](https://github.com/apache/kafka/blob/f46db86d34f9e5fe1b0d7604306a5108a89c113e/clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerCoordinator.java#L996C51-L996C72)
 until it gets the committed offsets from the coordinator (or the timeout 
expires). 
   - if not using committed offsets, it will just transition the partitions 
from init to awaiting_reset 
[here](https://github.com/apache/kafka/blob/f46db86d34f9e5fe1b0d7604306a5108a89c113e/clients/src/main/java/org/apache/kafka/clients/consumer/KafkaConsumer.java#L2450),
 and then the positions will be updated following the reset logic, that does 
not block.
    



-- 
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]

Reply via email to