davsclaus commented on code in PR #14768:
URL: https://github.com/apache/camel/pull/14768#discussion_r1671735359


##########
components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaFetchRecords.java:
##########
@@ -343,6 +371,30 @@ protected void startPolling() {
             final KafkaRecordProcessorFacade recordProcessorFacade = 
createRecordProcessor();
 
             while (isKafkaConsumerRunnableAndNotStopped() && isConnected() && 
pollExceptionStrategy.canContinue()) {
+
+                if (commitRecordsRequested.compareAndSet(true, false)) {
+                    try {
+                        // we want to get details about last committed offsets 
(which MUST be done by this consumer thread)
+                        Map<TopicPartition, OffsetAndMetadata> commits = 
consumer.committed(consumer.assignment());
+                        commitRecords.clear();
+                        for (var e : commits.entrySet()) {
+                            KafkaTopicPosition p
+                                    = new KafkaTopicPosition(
+                                            e.getKey().topic(), 
e.getKey().partition(), e.getValue().offset(),
+                                            
e.getValue().leaderEpoch().orElse(0));
+                            commitRecords.add(p);
+                        }
+                        CountDownLatch count = latch.get();
+                        if (count != null) {
+                            count.countDown();
+                        }
+                    } catch (Exception e) {
+                        // ignore cannot get last commit details
+                        LOG.debug("Cannot get last offset committed from Kafka 
brokers due to: {}. This exception is ignored.",
+                                e.getMessage(), e);
+                    }
+                }
+

Review Comment:
   added a check if dev console enabled to skip the CAS



-- 
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: commits-unsubscr...@camel.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to