lianetm commented on code in PR #14385: URL: https://github.com/apache/kafka/pull/14385#discussion_r1327784079
########## 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); + return ConsumerUtils.refreshCommittedOffsets(offsets, this.metadata, this.subscriptions); + } catch (org.apache.kafka.common.errors.TimeoutException e) { + log.error("Couldn't refresh committed offsets before timeout expired"); + return false; + } + } Review Comment: Yes, it is possible that not all were retrieved and we return false, just to indicate that the operation (retrieve offsets for all partitions that needed init) failed. This is the same behaviour of the current consumer. If current consumer times out when retrieving committed offsets [here](https://github.com/apache/kafka/blob/f46db86d34f9e5fe1b0d7604306a5108a89c113e/clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerCoordinator.java#L1035) , it will then return false on the `refreshCommittedOffsetsIfNeeded` [here](https://github.com/apache/kafka/blob/f46db86d34f9e5fe1b0d7604306a5108a89c113e/clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerCoordinator.java#L961). -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org