opershai opened a new pull request, #9932:
URL: https://github.com/apache/camel/pull/9932

   Bug CAMEL-18985 is caused by 
[SyncCommitManager.commit()](https://github.com/apache/camel/blob/camel-3.20.x/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/consumer/SyncCommitManager.java#L48)
 method which doesn't have logic to check whether auto-commit is enabled. As 
result of this 
[KafkaConsumer.commitSync()](https://kafka.apache.org/33/javadoc/org/apache/kafka/clients/consumer/KafkaConsumer.html#commitSync())
 method is getting called in scope of the 
[KafkaFetchRecords.startPolling()](https://github.com/apache/camel/blob/camel-3.20.x/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaFetchRecords.java#L343)
 method. The `KafkaConsumer.commitSync()` method commits offsets returned on 
the *last* `poll()` for all the subscribed list of topics and partitions 
regardless of the fact whether events have been successfully processed or not. 
It's undesirable behaviour, because the component is configured with 
`autoCommitEnable=false`, `allowMan
 ualCommit=true` and `breakOnFirstError=true` to guarantee "at least once" 
events processing. 
   
   The fix goes inline with existing logic in the 
[AsyncCommitManager.commit()](https://github.com/apache/camel/blob/camel-3.20.x/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/consumer/AsyncCommitManager.java#L50)
 method which respects the auto-commit configuration. Basically, the same logic 
is added to the 
[SyncCommitManager.commit()](https://github.com/apache/camel/blob/camel-3.20.x/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/consumer/SyncCommitManager.java#L48)
 as part of the fix.
   
   Also the auto-commit configuration was respected for sync/async/noop commits 
in the class `DefaultCommitManager` which was removed as part of the 
[refactoring](https://github.com/apache/camel/commit/2d46024a7836e7b24dce7257a17d4f9499c48f7b).


-- 
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