Hi Yeah, Kafka is really hard, it puts so many "problems" on the clients.
Your observation may be that if the while loop is exited due to break on first error, then maybe that auto commit should not be triggered. Maybe you can build an unit test that simulate this situation that would be good to have, and help with implementing a fix and have good test coverage. You are also welcome to create a JIRA On Tue, Sep 30, 2025 at 12:22 PM Stanislav Kascak < [email protected]> wrote: > Hi, > > I'm trying to define following scenario. > Imagine I have 3 messages in kafka topic and I start reading them with > camel route and processing of second message fails on exception. I would > like to start getting that second message until a (temporary) problem is > resolved. I would like to utilize auto commit if possible. > > Reading the docs, I would expect following kafka: configuration would > achieve that: > > autoCommitEnable=true > breakOnFirstError=true > allowManualCommit=false > > kafkaManualCommitFactory=#class:org.apache.camel.component.kafka.consumer.DefaultKafkaManualCommitFactory > > kafkaManualCommitFactory should change NoopCommitManager to > SyncCommitManager which positions the read offset in kafka to the failed > message once breakOnFirstError happens. Once the reading is restarted, I > should get the failed message again. > > However, this is not what I'm observing, as all the polled messages are > committed. Debugging, I traced that to > > https://github.com/apache/camel/blob/f141b63a266e5b180dec421bf3665ff808742ba6/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaFetchRecords.java#L405 > where the commit of all messages happens despite the error. > > Now my question is, whether my configuration wrong or I'm trying to use an > approach that does not make sense and I should use manual commit instead. > > Thanks for answer. > -- Claus Ibsen
