davsclaus opened a new pull request, #30798: URL: https://github.com/apache/camel/pull/30798
_Claude Code on behalf of Claus Ibsen (davsclaus)_ [CAMEL-27551](https://issues.apache.org/jira/browse/CAMEL-27551) ### Use the Kafka default for `partitionAssignor` `partitionAssignor` defaulted to `RangeAssignor`, and Camel always passed it as `partition.assignment.strategy`. Since Kafka 3.0 (KIP-726) the client default is `[RangeAssignor, CooperativeStickyAssignor]`. With that default the RangeAssignor still assigns the partitions, but a group can move to cooperative rebalancing with a single rolling restart that removes `RangeAssignor` from the list. With the Camel default, every member first had to add `CooperativeStickyAssignor` itself, which took one more rolling restart. The option is now unset by default, so Camel no longer sets `partition.assignment.strategy` and the Kafka default applies. The assignment does not change, also in a group where some members still run an older Camel version, since they all agree on `RangeAssignor`. The option description now explains the Kafka default. It is still ignored with `groupProtocol=consumer`. ### Seek only the partitions a rebalance assigned The ticket asked whether the rebalance code can handle incremental assignment, and it could not. With a cooperative assignor, or with `groupProtocol=consumer`, `onPartitionsAssigned` gets only the partitions the rebalance added (possibly none), and the consumer keeps reading the others from where it is. But `seekTo`, `offsetRepository` and a resume strategy moved every partition in `consumer.assignment()`, so the partitions the consumer kept were read again (`seekTo=BEGINNING`, `offsetRepository`) or skipped records (`seekTo=END`). This already happens today with `groupProtocol=consumer`. The new IT shows it against a real broker. Without the fix, consumer A re-reads its kept partition when consumer B joins: ``` consumer a must read each record of its kept partition once, but received [p0-0, p0-1, p0-2, p0-3, p0-4, p1-0, p1-1, p1-2, p1-3, p1-4, p0-0, p0-1, p0-2, p0-3, p0-4, marker] ==> expected: <11> but was: <16> ``` Now the rebalance listeners pass the assigned partitions on: - `PartitionAssignmentAdapter` gets `handlePartitionAssignment(Collection<TopicPartition>)`. It is a default method that calls the old one, so custom adapters keep working. `SeekPolicyPartitionAssignmentAdapter` and `OffsetPartitionAssignmentAdapter` implement it. - `KafkaResumeAdapter` gets `resume(Collection<TopicPartition>)`, which `ResumeRebalanceListener` uses. An eager assignor (such as `RangeAssignor`) assigns all the partitions of the consumer at every rebalance, so nothing changes there. ### Tests - `KafkaConfigurationPartitionAssignorTest`: the strategy is not set by default; a configured one is used; it is still left out with `groupProtocol=consumer`. - `ClassicRebalanceListenerTest`: `seekTo` BEGINNING/END and `offsetRepository` move only the assigned partitions; a rebalance that adds no partition does not seek; eager rebalancing still moves all partitions. Four of the five fail without the fix, and the eager one passes on both, as it should. - `KafkaResumeAdapterTest`: `resume(partitions)` seeks only the given partitions. - `KafkaConsumerIncrementalRebalanceSeekIT`: two consumers on a 2-partition topic with `seekTo=BEGINNING`, once with `CooperativeStickyAssignor` and once with `groupProtocol=consumer`. Both fail without the fix (output above) and pass with it. `KafkaConsumerRebalanceIT` and `KafkaConsumerGroupProtocolIT` pass too. - All camel-kafka unit tests pass (1461). The upgrade guide has an entry for the new default and the seek change. The catalog and the component and endpoint DSLs are regenerated. This PR and #30795 (CAMEL-27549: camel-kafka – align option descriptions with the Kafka docs) both regenerate `kafka.json` and the DSLs, so whichever merges second needs a regen. 🤖 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]
