CodeSmell commented on code in PR #11960: URL: https://github.com/apache/camel/pull/11960#discussion_r1388494228
########## components/camel-kafka/src/main/java/org/apache/camel/component/kafka/consumer/support/KafkaRecordProcessorFacade.java: ########## @@ -54,49 +54,53 @@ private boolean isStopping() { return camelKafkaConsumer.isStopping(); } - public ProcessingResult processPolledRecords( - ConsumerRecords<Object, Object> allRecords, ProcessingResult resultFromPreviousPoll) { + public ProcessingResult processPolledRecords( ConsumerRecords<Object, Object> allRecords) { logRecords(allRecords); + + ProcessingResult result = ProcessingResult.newUnprocessed(); Set<TopicPartition> partitions = allRecords.partitions(); Iterator<TopicPartition> partitionIterator = partitions.iterator(); - - ProcessingResult lastResult - = resultFromPreviousPoll == null ? ProcessingResult.newUnprocessed() : resultFromPreviousPoll; + + LOG.debug("Poll received records on {} partitions", partitions.size()); while (partitionIterator.hasNext() && !isStopping()) { TopicPartition partition = partitionIterator.next(); + LOG.debug("Processing records on partition {}", partition.partition()); + List<ConsumerRecord<Object, Object>> partitionRecords = allRecords.records(partition); Iterator<ConsumerRecord<Object, Object>> recordIterator = partitionRecords.iterator(); logRecordsInPartition(partitionRecords, partition); - while (!lastResult.isBreakOnErrorHit() && recordIterator.hasNext() && !isStopping()) { + while (!result.isBreakOnErrorHit() && recordIterator.hasNext() && !isStopping()) { ConsumerRecord<Object, Object> record = recordIterator.next(); - lastResult = processRecord(partition, partitionIterator.hasNext(), recordIterator.hasNext(), lastResult, + LOG.debug("Processing record on partition {} with offset {}", record.partition(), record.offset()); + + result = processRecord(partition, partitionIterator.hasNext(), recordIterator.hasNext(), kafkaRecordProcessor, record); - LOG.debug("Processed record on partition {} and offset {} and got result for partition {} and offset {}", - record.partition(), record.offset(), lastResult.getPartition(), lastResult.getPartitionLastOffset()); + LOG.debug("Processed record on partition {} with offset {} and got ProcessingResult for partition {} and offset {}", + record.partition(), record.offset(), result.getPartition(), result.getPartitionLastOffset()); if (consumerListener != null) { - if (!consumerListener.afterProcess(lastResult)) { + if (!consumerListener.afterProcess(result)) { commitManager.commit(partition); - return lastResult; + return result; } } } - if (!lastResult.isBreakOnErrorHit()) { + if (!result.isBreakOnErrorHit()) { Review Comment: this part of the code is one of 2 reasons I can see that we need the offset in `ProcessedResult` may be worth trying to move it inside `createExchange` -- 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