philipnee commented on code in PR #14710:
URL: https://github.com/apache/kafka/pull/14710#discussion_r1400074015
##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/ConsumerNetworkThread.java:
##########
@@ -257,10 +257,77 @@ private void closeInternal(final Duration timeout) {
void cleanup() {
log.trace("Closing the consumer network thread");
Timer timer = time.timer(closeTimeout);
+ waitForClosingTasks(timer);
runAtClose(requestManagers.entries(), networkClientDelegate, timer);
closeQuietly(requestManagers, "request managers");
closeQuietly(networkClientDelegate, "network client delegate");
closeQuietly(applicationEventProcessor, "application event processor");
log.debug("Closed the consumer network thread");
}
+
+ /**
+ * We need to autocommit before shutting down the consumer. The method
needs to first connect to the coordinator
+ * node to construct the closing requests. Then wait for all closing
requests to finish before returning. The
+ * method is bounded by a closing timer. We will continue closing down
the consumer if the requests cannot be
+ * completed in time.
+ */
+ // Visible for testing
+ void waitForClosingTasks(final Timer timer) {
Review Comment:
You are right. I think the original code is actually less confusing because
sending auto commits needs to happen before closing down the
`ConsumerCoordinator`. Now these tasks (closingTasks here) are the operations
that need to happen before closing the network thread (Because we are shutting
down the consumer).
I wonder if I could make it less confusing by renaming the method. See the
changes there.
--
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]