allthingssecurity opened a new pull request, #30361: URL: https://github.com/apache/camel/pull/30361
# Description [CAMEL-26967](https://issues.apache.org/jira/browse/CAMEL-26967) Backport of #30132 (CAMEL-26967) to camel-4.22.x. With `breakOnFirstError=true` and synchronous manual commits, a failed record makes the consumer commit the records before it and break out, so it reconnects and polls the failed record again. When that `commitSync` threw (a `TimeoutException`, or `CommitFailedException` / `RebalanceInProgressException`), the exception left the batch and went to the `pollOnError` strategy. With `ERROR_HANDLER` (the default), `DISCARD` or `RETRY`, the fetcher went on polling with the same Kafka consumer, whose position was after the whole poll, so the failed record and the rest of the poll were never routed. `camel-4.22.x` has the same code in `KafkaRecordStreamingProcessor.processException` and the same poll loop, so it has the same bug. The fix is the same as on main: a `KafkaException` of that commit (not `WakeupException` or `InterruptException`) is reported to the exception handler of the consumer, and the break is returned as before, so the new Kafka consumer polls again from the committed offset. What differs from main: - `KafkaRecordStreamingProcessor` on this branch is much older than on main, so the change is applied by hand to the same `commitManager.commit(topicPartition)` call; the new code (the try/catch, its comments and the log message) is the same text as on main. - The new `KafkaConsumerBreakOnFirstErrorCommitTimeoutTest` is the same file as on main. - The Kafka DST world of CAMEL-26947 is not on this branch, so the `KafkaWorld` change and its generated catalog / `test-dst.adoc` entries are left out. - No upgrade-guide change here: as AGENTS.md asks, the note for 4.22.x users (the exception now goes to the exception handler of the consumer instead of `pollOnError`) belongs on main, in the 4.22 guide under "Upgrading from 4.22.2 to 4.22.3"; I will add it there in a small follow-up on main. Tests on `camel-4.22.x` (offline): `KafkaConsumerBreakOnFirstErrorCommitTimeoutTest` 5/5, and 50/50 over 10 runs; camel-kafka unit tests 201 run, 0 failures, 1 skipped (ITs not run). Negative control: on `camel-4.22.x` without the fix 4 of the 5 tests fail as on main (routed `[a, b, f]` instead of `[a, b, c, d, e, f]` for `ERROR_HANDLER`, `DISCARD` and `RETRY`, and nothing reported to the exception handler); the `RECONNECT` control passes. # Target - [x] I checked that the commit is targeting the correct branch (this is a backport to `camel-4.22.x`) # Tracking - [x] If this is a large change, bug fix, or code improvement, I checked there is a [JIRA issue](https://issues.apache.org/jira/browse/CAMEL) filed for the change (usually before you start working on it): [CAMEL-26967](https://issues.apache.org/jira/browse/CAMEL-26967). # Apache Camel coding standards and style - [x] I checked that each commit in the pull request has a meaningful subject line and body. - [ ] I have run `mvn clean install -DskipTests` locally from root folder and I have committed all auto-generated changes. (I built camel-kafka of `camel-4.22.x` with the formatter and import-sort plugins and ran the tests above; no generated file changes. I did not run the full root build.) # AI-assisted contributions - [x] If this PR includes AI-generated code, commits have proper co-authorship attribution (e.g., `Co-authored-by` trailers) and the PR description identifies the AI tool used. This PR was prepared with Claude Code (Claude Opus 5.5). The commit carries a `Co-Authored-By` trailer. _Claude Code on behalf of allthingssecurity_ 🤖 Generated with [Claude Code](https://claude.com/claude-code) -- 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]
