orpiske commented on code in PR #14768:
URL: https://github.com/apache/camel/pull/14768#discussion_r1671674901
##########
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:
> No its only in use on special request
So yeah, that's my point. We are calling `compareAndSet` here which, even
though is an Intrinsic method, may actually cause memory overhead due to need
to perform CAS.
So, even though an integration doesn't need the console, it would still be
subject to this, which could hurt performance.
--
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]