Claus Ibsen created CAMEL-27892:
-----------------------------------
Summary: camel-kafka: breakOnFirstError skips a failed batch, a
later batch commits past a failed one, seekTo seeks again on every partition
assignment
Key: CAMEL-27892
URL: https://issues.apache.org/jira/browse/CAMEL-27892
Project: Camel
Issue Type: Bug
Components: camel-kafka
Reporter: Claus Ibsen
Fix For: 4.25.0
Found while improving the option descriptions of camel-kafka for CAMEL-23832
(pull request https://github.com/apache/camel/pull/31159).
These are separate problems of the component; the descriptions change only
documents the current behavior.
h4. 1. breakOnFirstError skips a failed batch
With batching, breakOnFirstError and auto commit,
{{KafkaRecordBatchingProcessor.CommitSynchronization.onFailure}} commits the
offsets of the failed batch before the consumer reconnects, so the batch is
skipped, not retried. The doc page and the code comment say it is retried,
while KafkaBatchingProcessingBreakOnFirstErrorIT expects the skip.
Proposed change: commit nothing for the failed batch, or fix the doc and the
intent of the IT.
h4. 2. A later batch commits past a failed one
With batching and without breakOnFirstError, a failed batch is not committed,
but the next successful batch commits past it (AsyncCommitManager keeps the
highest offset), so the failed batch is only read again after a rebalance or
restart. The log message "Will attempt to process the message on next poll" is
misleading.
Proposed change: decide the intended behavior, and fix the log message.
h4. 3. seekTo seeks on every partition assignment
{{KafkaFetchRecords.subscribe}} creates a new ClassicRebalanceListener and
SeekPolicyPartitionAssignmentAdapter for each new Kafka consumer, so the seek
runs on every assignment: after breakOnFirstError or pollOnError=RECONNECT,
BEGINNING replays the whole partition and END skips the records after the
failed one; rebalances in a group trigger it too. The doc page says "on each
consumer start".
Proposed change: seek only on the first assignment of a partition after the
route starts.
h4. 4. Key and partition precedence differ for an Iterable body
In {{KeyValueHolderIterator.next()}}, the CamelKafkaKey header of an Exchange
or Message element wins over the key option (a single record does the
opposite); for a plain element the record has no partition, so the partitionKey
option and the outer CamelKafkaPartitionKey, CamelKafkaKey and
CamelKafkaOverrideTimestamp headers are ignored.
Proposed change: use one precedence everywhere (option, then header).
h4. 5. autoCommitEnable=false alone commits nothing
Without allowManualCommit, offsetRepository or batching,
CommitManagers.createCommitManager selects the NoopCommitManager, so no offsets
are ever committed.
Proposed change: log a WARN, or use the SyncCommitManager.
h4. 6. Header texts in camel-kafka-common
CamelKafkaPartitionKey/CamelKafkaKey do not say that the options win,
CamelKafkaOverrideTimestamp is garbled, CamelKafkaManualCommit is only set with
allowManualCommit, createConsumerBackoffInterval says "millis seconds", and
sslKeymanagerAlgorithm/sslTrustmanagerAlgorithm say the JVM default while Camel
passes SunX509 and PKIX. These texts are shared with camel-kafka-share and were
left for a separate change.
_Claude Code on behalf of davsclaus_
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)