You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2021/10/18 13:32:34 UTC

[GitHub] [camel] davsclaus commented on a change in pull request #6292: CAMEL-17096: Add async commit support in camel-kafka component

davsclaus commented on a change in pull request #6292:
URL: https://github.com/apache/camel/pull/6292#discussion_r730922524



##########
File path: components/camel-kafka/src/main/java/org/apache/camel/component/kafka/DefaultKafkaManualCommit.java
##########
@@ -70,6 +83,26 @@ protected void commitOffset(StateRepository<String, String> offsetRepository, To
         }
     }
 
+    protected void commitAsyncOffset(
+            StateRepository<String, String> offsetRepository, TopicPartition partition, long recordOffset) {
+        if (recordOffset != -1) {
+            if (offsetRepository != null) {
+                offsetRepository.setState(serializeOffsetKey(partition), serializeOffsetValue(recordOffset));
+            } else {
+                LOG.debug("CommitAsync {} from topic {} with offset: {}", threadId, topicName, recordOffset);
+                consumer.commitAsync(Collections.singletonMap(partition, new OffsetAndMetadata(recordOffset + 1)),
+                        (offsets, exception) -> {
+                            if (exception != null) {
+                                LOG.error("Error during async commit: ", exception);
+                            } else {
+                                LOG.info("CommitAsync done for {} from topic {} with offset: {}", threadId, topicName,

Review comment:
       Reduce logging noise as INFO is too verbose, use DEBUG or TRACE

##########
File path: components/camel-kafka/src/main/java/org/apache/camel/component/kafka/DefaultKafkaManualCommit.java
##########
@@ -70,6 +83,26 @@ protected void commitOffset(StateRepository<String, String> offsetRepository, To
         }
     }
 
+    protected void commitAsyncOffset(
+            StateRepository<String, String> offsetRepository, TopicPartition partition, long recordOffset) {
+        if (recordOffset != -1) {
+            if (offsetRepository != null) {
+                offsetRepository.setState(serializeOffsetKey(partition), serializeOffsetValue(recordOffset));
+            } else {
+                LOG.debug("CommitAsync {} from topic {} with offset: {}", threadId, topicName, recordOffset);
+                consumer.commitAsync(Collections.singletonMap(partition, new OffsetAndMetadata(recordOffset + 1)),
+                        (offsets, exception) -> {
+                            if (exception != null) {
+                                LOG.error("Error during async commit: ", exception);

Review comment:
       You can maybe add more details to this error message about topic, offset etc




-- 
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-unsubscribe@camel.apache.org

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