kirktrue commented on code in PR #20521:
URL: https://github.com/apache/kafka/pull/20521#discussion_r2407119295
##########
clients/src/main/java/org/apache/kafka/clients/consumer/internals/events/ApplicationEventProcessor.java:
##########
@@ -726,6 +728,67 @@ private void process(final
StreamsOnAllTasksLostCallbackCompletedEvent event) {
requestManagers.streamsMembershipManager.get().onAllTasksLostCallbackCompleted(event);
}
+ private void process(final AsyncPollEvent event) {
+ AsyncPollEventProcessorContext context =
asyncPollContext.orElseThrow(IllegalArgumentException::new);
+ ApplicationEvent.Type nextEventType = event.startingEventType();
+
+ if (context.maybeCompleteExceptionally(event) ||
context.maybeCompleteWithCallbackRequired(event, nextEventType))
+ return;
+
+ if (nextEventType == ApplicationEvent.Type.ASYNC_POLL) {
+ log.trace("Processing {} logic for {}", nextEventType, event);
+
+ // Trigger a reconciliation that can safely commit offsets if
needed to rebalance,
+ // as we're processing before any new fetching starts
+
requestManagers.consumerMembershipManager.ifPresent(consumerMembershipManager ->
+ consumerMembershipManager.maybeReconcile(true));
+
+ if (requestManagers.commitRequestManager.isPresent()) {
+ CommitRequestManager commitRequestManager =
requestManagers.commitRequestManager.get();
+
commitRequestManager.updateTimerAndMaybeCommit(event.pollTimeMs());
+
+ requestManagers.consumerHeartbeatRequestManager.ifPresent(hrm
-> {
+ hrm.membershipManager().onConsumerPoll();
+ hrm.resetPollTimer(event.pollTimeMs());
+ });
+
requestManagers.streamsGroupHeartbeatRequestManager.ifPresent(hrm -> {
+ hrm.membershipManager().onConsumerPoll();
+ hrm.resetPollTimer(event.pollTimeMs());
+ });
+ }
+
+ nextEventType = ApplicationEvent.Type.CHECK_AND_UPDATE_POSITIONS;
Review Comment:
Yes, this has been refactored. PTAL at the latest. Thanks!
--
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]