philipnee commented on code in PR #13380:
URL: https://github.com/apache/kafka/pull/13380#discussion_r1148140557


##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/CommitRequestManager.java:
##########
@@ -113,15 +112,45 @@ private void maybeAutoCommit(final long currentTimeMs) {
         }
 
         Map<TopicPartition, OffsetAndMetadata> allConsumedOffsets = 
subscriptionState.allConsumed();
-        log.debug("Auto-committing offsets {}", allConsumedOffsets);
         sendAutoCommit(allConsumedOffsets);
         autocommit.resetTimer();
+    }
+
+    /**
+     * Handles {@link 
org.apache.kafka.clients.consumer.internals.events.CommitApplicationEvent}. It 
creates an
+     * {@link UnsentOffsetCommitRequest} and enqueue it to send later.
+     */
+    public CompletableFuture<ClientResponse> addOffsetCommitRequest(final 
Map<TopicPartition, OffsetAndMetadata> offsets) {
+        return pendingRequests.addOffsetCommitRequest(offsets);
+    }
+
+    /**
+     * Handles {@link 
org.apache.kafka.clients.consumer.internals.events.OffsetFetchApplicationEvent}.
 It creates an
+     * {@link UnsentOffsetFetchRequest} and enqueue it to send later.
+     */
+    public CompletableFuture<Map<TopicPartition, OffsetAndMetadata>> 
addOffsetFetchRequest(final Set<TopicPartition> partitions) {
+        return pendingRequests.addOffsetFetchRequest(partitions);
+    }
+
+    public void clientPoll(final long currentTimeMs) {
+        this.autoCommitState.ifPresent(t -> t.ack(currentTimeMs));
+    }
+
 
+    // Visible for testing
+    List<UnsentOffsetFetchRequest> unsentOffsetFetchRequests() {
+        return pendingRequests.unsentOffsetFetches;
+    }
+
+    // Visible for testing
+    Queue<UnsentOffsetCommitRequest> unsentOffsetCommitRequests() {
+        return pendingRequests.unsentOffsetCommits;
     }
 
     // Visible for testing
     CompletableFuture<ClientResponse> sendAutoCommit(final Map<TopicPartition, 
OffsetAndMetadata> allConsumedOffsets) {
-        CompletableFuture<ClientResponse> future = this.add(allConsumedOffsets)
+        log.debug("Enqueuing autocommit offsets: {}", allConsumedOffsets);
+        return this.addOffsetCommitRequest(allConsumedOffsets)

Review Comment:
   Hey I somehow thought I addressed this comment by setting the 
`hasInflightCommit` but I somehow can't find it here.  I'll follow this up with 
a commit - along with testing the commit callback. Sorry about that.



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

Reply via email to