This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 0a7abfa57f8b CAMEL-27551: camel-kafka - Use the Kafka default for
partitionAssignor (#30798)
0a7abfa57f8b is described below
commit 0a7abfa57f8b7c9b9d7591f56bf0d21f3c10e180
Author: Claus Ibsen <[email protected]>
AuthorDate: Wed Nov 25 21:53:30 2026 +0100
CAMEL-27551: camel-kafka - Use the Kafka default for partitionAssignor
(#30798)
partitionAssignor defaulted to RangeAssignor and was always passed as
partition.assignment.strategy. The option is now unset by default, so the Kafka
client default [RangeAssignor, CooperativeStickyAssignor] applies: the
assignment does not change, but a group can move to cooperative rebalancing
with a single rolling restart.
With incremental assignment (a cooperative assignor, or
groupProtocol=consumer), onPartitionsAssigned gets only the partitions the
rebalance added, but seekTo, offsetRepository and a resume strategy moved every
partition of the consumer, so kept partitions were read again or skipped
records. The rebalance listeners now pass the assigned partitions on:
PartitionAssignmentAdapter gets
handlePartitionAssignment(Collection<TopicPartition>) (a default method calling
the old one, so custom [...]
The upgrade guide has an entry for the new default and the seek change.
Closes #30798
Co-Authored-By: Claude Opus 5.5 <[email protected]>
---
.../org/apache/camel/catalog/components/kafka.json | 4 +-
.../org/apache/camel/component/kafka/kafka.json | 4 +-
.../camel/component/kafka/KafkaConfiguration.java | 12 +-
.../support/classic/ClassicRebalanceListener.java | 4 +-
.../classic/OffsetPartitionAssignmentAdapter.java | 11 +-
.../classic/PartitionAssignmentAdapter.java | 18 +++
.../SeekPolicyPartitionAssignmentAdapter.java | 19 ++-
.../support/resume/KafkaResumeAdapter.java | 18 +++
.../support/resume/ResumeRebalanceListener.java | 4 +-
.../KafkaConfigurationPartitionAssignorTest.java | 62 ++++++++++
.../classic/ClassicRebalanceListenerTest.java | 118 +++++++++++++++++++
.../support/resume/KafkaResumeAdapterTest.java | 23 ++++
.../KafkaConsumerIncrementalRebalanceSeekIT.java | 129 +++++++++++++++++++++
.../ROOT/pages/camel-4x-upgrade-guide-4_24.adoc | 18 +++
.../dsl/KafkaComponentBuilderFactory.java | 15 ++-
.../endpoint/dsl/KafkaEndpointBuilderFactory.java | 14 ++-
16 files changed, 447 insertions(+), 26 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/kafka.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/kafka.json
index 59de05096081..b5273943d680 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/kafka.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/kafka.json
@@ -68,7 +68,7 @@
"maxPollIntervalMs": { "index": 41, "kind": "property", "displayName":
"Max Poll Interval Ms", "group": "consumer", "label": "consumer", "required":
false, "type": "duration", "javaType": "java.lang.Integer", "deprecated":
false, "autowired": false, "secret": false, "defaultValue": "300000",
"configurationClass": "org.apache.camel.component.kafka.KafkaConfiguration",
"configurationField": "configuration", "description": "The maximum delay
between invocations of poll() when using cons [...]
"maxPollRecords": { "index": 42, "kind": "property", "displayName": "Max
Poll Records", "group": "consumer", "label": "consumer", "required": false,
"type": "integer", "javaType": "java.lang.Integer", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": 500, "configurationClass":
"org.apache.camel.component.kafka.KafkaConfiguration", "configurationField":
"configuration", "description": "The maximum number of records returned in a
single call to poll()" },
"offsetRepository": { "index": 43, "kind": "property", "displayName":
"Offset Repository", "group": "consumer", "label": "consumer", "required":
false, "type": "object", "javaType":
"org.apache.camel.spi.StateRepository<java.lang.String, java.lang.String>",
"deprecated": false, "autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.kafka.KafkaConfiguration", "configurationField":
"configuration", "description": "The offset repository to use to locally [...]
- "partitionAssignor": { "index": 44, "kind": "property", "displayName":
"Partition Assignor", "group": "consumer", "label": "consumer", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "defaultValue":
"org.apache.kafka.clients.consumer.RangeAssignor", "configurationClass":
"org.apache.camel.component.kafka.KafkaConfiguration", "configurationField":
"configuration", "description": "The class name of the parti [...]
+ "partitionAssignor": { "index": 44, "kind": "property", "displayName":
"Partition Assignor", "group": "consumer", "label": "consumer", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.kafka.KafkaConfiguration", "configurationField":
"configuration", "description": "The class names of the partition assignment
strategies, ordered by preference, that the client [...]
"pollOnError": { "index": 45, "kind": "property", "displayName": "Poll On
Error", "group": "consumer", "label": "consumer", "required": false, "type":
"enum", "javaType": "org.apache.camel.component.kafka.PollOnError", "enum": [
"DISCARD", "ERROR_HANDLER", "RECONNECT", "RETRY", "STOP" ], "deprecated":
false, "autowired": false, "secret": false, "defaultValue": "ERROR_HANDLER",
"configurationClass": "org.apache.camel.component.kafka.KafkaConfiguration",
"configurationField": "configur [...]
"pollTimeoutMs": { "index": 46, "kind": "property", "displayName": "Poll
Timeout Ms", "group": "consumer", "label": "consumer", "required": false,
"type": "duration", "javaType": "java.lang.Long", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": "5000",
"configurationClass": "org.apache.camel.component.kafka.KafkaConfiguration",
"configurationField": "configuration", "description": "The timeout used when
polling the KafkaConsumer." },
"preValidateHostAndPort": { "index": 47, "kind": "property",
"displayName": "Pre Validate Host And Port", "group": "consumer", "label":
"consumer", "required": false, "type": "boolean", "javaType": "boolean",
"deprecated": false, "autowired": false, "secret": false, "defaultValue": true,
"configurationClass": "org.apache.camel.component.kafka.KafkaConfiguration",
"configurationField": "configuration", "description": "Whether to eager
validate that broker host:port is valid and can be [...]
@@ -228,7 +228,7 @@
"maxPollIntervalMs": { "index": 40, "kind": "parameter", "displayName":
"Max Poll Interval Ms", "group": "consumer", "label": "consumer", "required":
false, "type": "duration", "javaType": "java.lang.Integer", "deprecated":
false, "autowired": false, "secret": false, "defaultValue": "300000",
"configurationClass": "org.apache.camel.component.kafka.KafkaConfiguration",
"configurationField": "configuration", "description": "The maximum delay
between invocations of poll() when using con [...]
"maxPollRecords": { "index": 41, "kind": "parameter", "displayName": "Max
Poll Records", "group": "consumer", "label": "consumer", "required": false,
"type": "integer", "javaType": "java.lang.Integer", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": 500, "configurationClass":
"org.apache.camel.component.kafka.KafkaConfiguration", "configurationField":
"configuration", "description": "The maximum number of records returned in a
single call to poll()" },
"offsetRepository": { "index": 42, "kind": "parameter", "displayName":
"Offset Repository", "group": "consumer", "label": "consumer", "required":
false, "type": "object", "javaType":
"org.apache.camel.spi.StateRepository<java.lang.String, java.lang.String>",
"deprecated": false, "autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.kafka.KafkaConfiguration", "configurationField":
"configuration", "description": "The offset repository to use to locally [...]
- "partitionAssignor": { "index": 43, "kind": "parameter", "displayName":
"Partition Assignor", "group": "consumer", "label": "consumer", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "defaultValue":
"org.apache.kafka.clients.consumer.RangeAssignor", "configurationClass":
"org.apache.camel.component.kafka.KafkaConfiguration", "configurationField":
"configuration", "description": "The class name of the part [...]
+ "partitionAssignor": { "index": 43, "kind": "parameter", "displayName":
"Partition Assignor", "group": "consumer", "label": "consumer", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.kafka.KafkaConfiguration", "configurationField":
"configuration", "description": "The class names of the partition assignment
strategies, ordered by preference, that the clien [...]
"pollOnError": { "index": 44, "kind": "parameter", "displayName": "Poll On
Error", "group": "consumer", "label": "consumer", "required": false, "type":
"enum", "javaType": "org.apache.camel.component.kafka.PollOnError", "enum": [
"DISCARD", "ERROR_HANDLER", "RECONNECT", "RETRY", "STOP" ], "deprecated":
false, "autowired": false, "secret": false, "defaultValue": "ERROR_HANDLER",
"configurationClass": "org.apache.camel.component.kafka.KafkaConfiguration",
"configurationField": "configu [...]
"pollTimeoutMs": { "index": 45, "kind": "parameter", "displayName": "Poll
Timeout Ms", "group": "consumer", "label": "consumer", "required": false,
"type": "duration", "javaType": "java.lang.Long", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": "5000",
"configurationClass": "org.apache.camel.component.kafka.KafkaConfiguration",
"configurationField": "configuration", "description": "The timeout used when
polling the KafkaConsumer." },
"preValidateHostAndPort": { "index": 46, "kind": "parameter",
"displayName": "Pre Validate Host And Port", "group": "consumer", "label":
"consumer", "required": false, "type": "boolean", "javaType": "boolean",
"deprecated": false, "autowired": false, "secret": false, "defaultValue": true,
"configurationClass": "org.apache.camel.component.kafka.KafkaConfiguration",
"configurationField": "configuration", "description": "Whether to eager
validate that broker host:port is valid and can b [...]
diff --git
a/components/camel-kafka/src/generated/resources/META-INF/org/apache/camel/component/kafka/kafka.json
b/components/camel-kafka/src/generated/resources/META-INF/org/apache/camel/component/kafka/kafka.json
index 59de05096081..b5273943d680 100644
---
a/components/camel-kafka/src/generated/resources/META-INF/org/apache/camel/component/kafka/kafka.json
+++
b/components/camel-kafka/src/generated/resources/META-INF/org/apache/camel/component/kafka/kafka.json
@@ -68,7 +68,7 @@
"maxPollIntervalMs": { "index": 41, "kind": "property", "displayName":
"Max Poll Interval Ms", "group": "consumer", "label": "consumer", "required":
false, "type": "duration", "javaType": "java.lang.Integer", "deprecated":
false, "autowired": false, "secret": false, "defaultValue": "300000",
"configurationClass": "org.apache.camel.component.kafka.KafkaConfiguration",
"configurationField": "configuration", "description": "The maximum delay
between invocations of poll() when using cons [...]
"maxPollRecords": { "index": 42, "kind": "property", "displayName": "Max
Poll Records", "group": "consumer", "label": "consumer", "required": false,
"type": "integer", "javaType": "java.lang.Integer", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": 500, "configurationClass":
"org.apache.camel.component.kafka.KafkaConfiguration", "configurationField":
"configuration", "description": "The maximum number of records returned in a
single call to poll()" },
"offsetRepository": { "index": 43, "kind": "property", "displayName":
"Offset Repository", "group": "consumer", "label": "consumer", "required":
false, "type": "object", "javaType":
"org.apache.camel.spi.StateRepository<java.lang.String, java.lang.String>",
"deprecated": false, "autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.kafka.KafkaConfiguration", "configurationField":
"configuration", "description": "The offset repository to use to locally [...]
- "partitionAssignor": { "index": 44, "kind": "property", "displayName":
"Partition Assignor", "group": "consumer", "label": "consumer", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "defaultValue":
"org.apache.kafka.clients.consumer.RangeAssignor", "configurationClass":
"org.apache.camel.component.kafka.KafkaConfiguration", "configurationField":
"configuration", "description": "The class name of the parti [...]
+ "partitionAssignor": { "index": 44, "kind": "property", "displayName":
"Partition Assignor", "group": "consumer", "label": "consumer", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.kafka.KafkaConfiguration", "configurationField":
"configuration", "description": "The class names of the partition assignment
strategies, ordered by preference, that the client [...]
"pollOnError": { "index": 45, "kind": "property", "displayName": "Poll On
Error", "group": "consumer", "label": "consumer", "required": false, "type":
"enum", "javaType": "org.apache.camel.component.kafka.PollOnError", "enum": [
"DISCARD", "ERROR_HANDLER", "RECONNECT", "RETRY", "STOP" ], "deprecated":
false, "autowired": false, "secret": false, "defaultValue": "ERROR_HANDLER",
"configurationClass": "org.apache.camel.component.kafka.KafkaConfiguration",
"configurationField": "configur [...]
"pollTimeoutMs": { "index": 46, "kind": "property", "displayName": "Poll
Timeout Ms", "group": "consumer", "label": "consumer", "required": false,
"type": "duration", "javaType": "java.lang.Long", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": "5000",
"configurationClass": "org.apache.camel.component.kafka.KafkaConfiguration",
"configurationField": "configuration", "description": "The timeout used when
polling the KafkaConsumer." },
"preValidateHostAndPort": { "index": 47, "kind": "property",
"displayName": "Pre Validate Host And Port", "group": "consumer", "label":
"consumer", "required": false, "type": "boolean", "javaType": "boolean",
"deprecated": false, "autowired": false, "secret": false, "defaultValue": true,
"configurationClass": "org.apache.camel.component.kafka.KafkaConfiguration",
"configurationField": "configuration", "description": "Whether to eager
validate that broker host:port is valid and can be [...]
@@ -228,7 +228,7 @@
"maxPollIntervalMs": { "index": 40, "kind": "parameter", "displayName":
"Max Poll Interval Ms", "group": "consumer", "label": "consumer", "required":
false, "type": "duration", "javaType": "java.lang.Integer", "deprecated":
false, "autowired": false, "secret": false, "defaultValue": "300000",
"configurationClass": "org.apache.camel.component.kafka.KafkaConfiguration",
"configurationField": "configuration", "description": "The maximum delay
between invocations of poll() when using con [...]
"maxPollRecords": { "index": 41, "kind": "parameter", "displayName": "Max
Poll Records", "group": "consumer", "label": "consumer", "required": false,
"type": "integer", "javaType": "java.lang.Integer", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": 500, "configurationClass":
"org.apache.camel.component.kafka.KafkaConfiguration", "configurationField":
"configuration", "description": "The maximum number of records returned in a
single call to poll()" },
"offsetRepository": { "index": 42, "kind": "parameter", "displayName":
"Offset Repository", "group": "consumer", "label": "consumer", "required":
false, "type": "object", "javaType":
"org.apache.camel.spi.StateRepository<java.lang.String, java.lang.String>",
"deprecated": false, "autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.kafka.KafkaConfiguration", "configurationField":
"configuration", "description": "The offset repository to use to locally [...]
- "partitionAssignor": { "index": 43, "kind": "parameter", "displayName":
"Partition Assignor", "group": "consumer", "label": "consumer", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "defaultValue":
"org.apache.kafka.clients.consumer.RangeAssignor", "configurationClass":
"org.apache.camel.component.kafka.KafkaConfiguration", "configurationField":
"configuration", "description": "The class name of the part [...]
+ "partitionAssignor": { "index": 43, "kind": "parameter", "displayName":
"Partition Assignor", "group": "consumer", "label": "consumer", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "configurationClass":
"org.apache.camel.component.kafka.KafkaConfiguration", "configurationField":
"configuration", "description": "The class names of the partition assignment
strategies, ordered by preference, that the clien [...]
"pollOnError": { "index": 44, "kind": "parameter", "displayName": "Poll On
Error", "group": "consumer", "label": "consumer", "required": false, "type":
"enum", "javaType": "org.apache.camel.component.kafka.PollOnError", "enum": [
"DISCARD", "ERROR_HANDLER", "RECONNECT", "RETRY", "STOP" ], "deprecated":
false, "autowired": false, "secret": false, "defaultValue": "ERROR_HANDLER",
"configurationClass": "org.apache.camel.component.kafka.KafkaConfiguration",
"configurationField": "configu [...]
"pollTimeoutMs": { "index": 45, "kind": "parameter", "displayName": "Poll
Timeout Ms", "group": "consumer", "label": "consumer", "required": false,
"type": "duration", "javaType": "java.lang.Long", "deprecated": false,
"autowired": false, "secret": false, "defaultValue": "5000",
"configurationClass": "org.apache.camel.component.kafka.KafkaConfiguration",
"configurationField": "configuration", "description": "The timeout used when
polling the KafkaConsumer." },
"preValidateHostAndPort": { "index": 46, "kind": "parameter",
"displayName": "Pre Validate Host And Port", "group": "consumer", "label":
"consumer", "required": false, "type": "boolean", "javaType": "boolean",
"deprecated": false, "autowired": false, "secret": false, "defaultValue": true,
"configurationClass": "org.apache.camel.component.kafka.KafkaConfiguration",
"configurationField": "configuration", "description": "Whether to eager
validate that broker host:port is valid and can b [...]
diff --git
a/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaConfiguration.java
b/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaConfiguration.java
index 4f0d64f390a6..d7a111b4b2c0 100755
---
a/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaConfiguration.java
+++
b/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/KafkaConfiguration.java
@@ -81,8 +81,8 @@ public class KafkaConfiguration extends
KafkaClientConfiguration {
@UriParam(label = "consumer", defaultValue = "latest")
private String autoOffsetReset = "latest";
// partition.assignment.strategy
- @UriParam(label = "consumer", defaultValue =
KafkaConstants.PARTITIONER_RANGE_ASSIGNOR)
- private String partitionAssignor =
KafkaConstants.PARTITIONER_RANGE_ASSIGNOR;
+ @UriParam(label = "consumer")
+ private String partitionAssignor;
// group.protocol
@UriParam(label = "consumer", defaultValue = "classic", enums =
"classic,consumer")
private String groupProtocol = "classic";
@@ -897,8 +897,12 @@ public class KafkaConfiguration extends
KafkaClientConfiguration {
}
/**
- * The class name of the partition assignment strategy that the client
will use to distribute partition ownership
- * amongst consumer instances when group management is used
+ * The class names of the partition assignment strategies, ordered by
preference, that the client will use to
+ * distribute partition ownership amongst consumer instances when group
management is used. Multiple class names can
+ * be separated by comma. If not set, the Kafka default is used:
org.apache.kafka.clients.consumer.RangeAssignor and
+ * org.apache.kafka.clients.consumer.CooperativeStickyAssignor. This uses
the RangeAssignor, but allows upgrading to
+ * the CooperativeStickyAssignor with a single rolling restart that
removes the RangeAssignor from the list. This
+ * option is only used when groupProtocol is set to classic.
*/
public void setPartitionAssignor(String partitionAssignor) {
this.partitionAssignor = partitionAssignor;
diff --git
a/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/consumer/support/classic/ClassicRebalanceListener.java
b/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/consumer/support/classic/ClassicRebalanceListener.java
index 1782db9f9da4..2406676e73a3 100644
---
a/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/consumer/support/classic/ClassicRebalanceListener.java
+++
b/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/consumer/support/classic/ClassicRebalanceListener.java
@@ -79,6 +79,8 @@ public class ClassicRebalanceListener implements
ConsumerRebalanceListener {
partitions.forEach(p -> LOG.debug("onPartitionsAssigned: {} from
{}", threadId, p.topic()));
}
- assignmentAdapter.handlePartitionAssignment();
+ // only the partitions assigned by this rebalance: with a cooperative
assignor (or the consumer group protocol)
+ // the consumer keeps the partitions it already had, and their
position must not be moved
+ assignmentAdapter.handlePartitionAssignment(partitions);
}
}
diff --git
a/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/consumer/support/classic/OffsetPartitionAssignmentAdapter.java
b/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/consumer/support/classic/OffsetPartitionAssignmentAdapter.java
index a851659b8154..cd73cee47d16 100644
---
a/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/consumer/support/classic/OffsetPartitionAssignmentAdapter.java
+++
b/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/consumer/support/classic/OffsetPartitionAssignmentAdapter.java
@@ -16,7 +16,7 @@
*/
package org.apache.camel.component.kafka.consumer.support.classic;
-import java.util.Set;
+import java.util.Collection;
import org.apache.camel.spi.StateRepository;
import org.apache.kafka.clients.consumer.Consumer;
@@ -50,9 +50,14 @@ public class OffsetPartitionAssignmentAdapter implements
PartitionAssignmentAdap
consumer.seek(topicPartition, offset);
}
+ @Override
public void handlePartitionAssignment() {
- Set<TopicPartition> assignments = consumer.assignment();
- for (TopicPartition topicPartition : assignments) {
+ handlePartitionAssignment(consumer.assignment());
+ }
+
+ @Override
+ public void handlePartitionAssignment(Collection<TopicPartition>
partitions) {
+ for (TopicPartition topicPartition : partitions) {
String offsetState =
offsetRepository.getState(serializeOffsetKey(topicPartition));
if (offsetState != null && !offsetState.isEmpty()) {
resumeFromOffset(consumer, topicPartition, offsetState);
diff --git
a/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/consumer/support/classic/PartitionAssignmentAdapter.java
b/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/consumer/support/classic/PartitionAssignmentAdapter.java
index 634f59951ca6..52feac6531cc 100644
---
a/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/consumer/support/classic/PartitionAssignmentAdapter.java
+++
b/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/consumer/support/classic/PartitionAssignmentAdapter.java
@@ -16,7 +16,10 @@
*/
package org.apache.camel.component.kafka.consumer.support.classic;
+import java.util.Collection;
+
import org.apache.kafka.clients.consumer.Consumer;
+import org.apache.kafka.common.TopicPartition;
/**
* Defines a adapters for handling resume operations. Implementations can
define different ways to handle how to resume
@@ -40,4 +43,19 @@ public interface PartitionAssignmentAdapter {
* Callback for custom logic when partitions has been assigned.
*/
void handlePartitionAssignment();
+
+ /**
+ * Callback for custom logic when partitions has been assigned, with the
partitions that were assigned by the
+ * rebalance. With an eager assignor (such as RangeAssignor) these are all
the partitions of the consumer. With a
+ * cooperative assignor (such as CooperativeStickyAssignor) or the
consumer group protocol, these are only the
+ * partitions added by the rebalance (possibly none): the consumer keeps
reading the partitions it already had from
+ * where it is, so an implementation must not move them.
+ *
+ * The default implementation calls {@link #handlePartitionAssignment()}.
+ *
+ * @param partitions the partitions assigned by the rebalance
+ */
+ default void handlePartitionAssignment(Collection<TopicPartition>
partitions) {
+ handlePartitionAssignment();
+ }
}
diff --git
a/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/consumer/support/classic/SeekPolicyPartitionAssignmentAdapter.java
b/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/consumer/support/classic/SeekPolicyPartitionAssignmentAdapter.java
index b97839199d6e..336c3877186b 100644
---
a/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/consumer/support/classic/SeekPolicyPartitionAssignmentAdapter.java
+++
b/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/consumer/support/classic/SeekPolicyPartitionAssignmentAdapter.java
@@ -16,8 +16,11 @@
*/
package org.apache.camel.component.kafka.consumer.support.classic;
+import java.util.Collection;
+
import org.apache.camel.component.kafka.SeekPolicy;
import org.apache.kafka.clients.consumer.Consumer;
+import org.apache.kafka.common.TopicPartition;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@@ -42,12 +45,20 @@ public class SeekPolicyPartitionAssignmentAdapter
implements PartitionAssignment
@Override
public void handlePartitionAssignment() {
+ handlePartitionAssignment(consumer.assignment());
+ }
+
+ @Override
+ public void handlePartitionAssignment(Collection<TopicPartition>
partitions) {
+ if (partitions.isEmpty()) {
+ return;
+ }
if (seekPolicy == SeekPolicy.BEGINNING) {
- LOG.debug("Seeking from the beginning of topic");
- consumer.seekToBeginning(consumer.assignment());
+ LOG.debug("Seeking from the beginning of topic for partitions {}",
partitions);
+ consumer.seekToBeginning(partitions);
} else if (seekPolicy == SeekPolicy.END) {
- LOG.debug("Seeking from the end off the topic");
- consumer.seekToEnd(consumer.assignment());
+ LOG.debug("Seeking from the end of topic for partitions {}",
partitions);
+ consumer.seekToEnd(partitions);
}
}
}
diff --git
a/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/consumer/support/resume/KafkaResumeAdapter.java
b/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/consumer/support/resume/KafkaResumeAdapter.java
index 0757c63c634d..f8f8b16d03a8 100644
---
a/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/consumer/support/resume/KafkaResumeAdapter.java
+++
b/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/consumer/support/resume/KafkaResumeAdapter.java
@@ -18,6 +18,7 @@
package org.apache.camel.component.kafka.consumer.support.resume;
import java.nio.ByteBuffer;
+import java.util.Collection;
import org.apache.camel.resume.Cacheable;
import org.apache.camel.resume.Deserializable;
@@ -53,6 +54,23 @@ public class KafkaResumeAdapter implements ResumeAdapter,
Deserializable, Cachea
resumeCache.forEach(this::resume);
}
+ /**
+ * Resumes only the given partitions, such as the partitions assigned by a
rebalance. With a cooperative assignor
+ * (or the consumer group protocol) a rebalance assigns only the added
partitions, and the consumer keeps reading
+ * the partitions it already had from where it is.
+ *
+ * @param partitions the partitions to resume
+ */
+ public void resume(Collection<TopicPartition> partitions) {
+ resumeCache.forEach((topicPartition, value) -> {
+ if (partitions.contains(topicPartition)) {
+ resume(topicPartition, value);
+ }
+ // false keeps the entry in the cache
+ return false;
+ });
+ }
+
@Override
public boolean deserialize(ByteBuffer keyBuffer, ByteBuffer valueBuffer) {
Object keyObj = deserializeKey(keyBuffer);
diff --git
a/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/consumer/support/resume/ResumeRebalanceListener.java
b/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/consumer/support/resume/ResumeRebalanceListener.java
index d06cf20ee905..d088ce14d887 100644
---
a/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/consumer/support/resume/ResumeRebalanceListener.java
+++
b/components/camel-kafka/src/main/java/org/apache/camel/component/kafka/consumer/support/resume/ResumeRebalanceListener.java
@@ -80,7 +80,9 @@ public class ResumeRebalanceListener implements
ConsumerRebalanceListener {
partitions.forEach(p -> LOG.debug("onPartitionsAssigned: {} from
{}", threadId, p.topic()));
}
- resumeAdapter.resume();
+ // only the partitions assigned by this rebalance: with a cooperative
assignor (or the consumer group protocol)
+ // the consumer keeps the partitions it already had, and their
position must not be moved
+ resumeAdapter.resume(partitions);
}
}
diff --git
a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaConfigurationPartitionAssignorTest.java
b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaConfigurationPartitionAssignorTest.java
new file mode 100644
index 000000000000..9446e97df4db
--- /dev/null
+++
b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/KafkaConfigurationPartitionAssignorTest.java
@@ -0,0 +1,62 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kafka;
+
+import java.util.Properties;
+
+import org.apache.kafka.clients.consumer.ConsumerConfig;
+import org.apache.kafka.clients.consumer.CooperativeStickyAssignor;
+import org.junit.jupiter.api.Test;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+
+/**
+ * The partition assignment strategy is left to Kafka unless partitionAssignor
is set.
+ */
+class KafkaConfigurationPartitionAssignorTest {
+
+ @Test
+ void defaultUsesTheKafkaDefault() {
+ Properties props = new KafkaConfiguration().createConsumerProperties();
+
+ // not set: Kafka uses its default, [RangeAssignor,
CooperativeStickyAssignor]
+
assertFalse(props.containsKey(ConsumerConfig.PARTITION_ASSIGNMENT_STRATEGY_CONFIG));
+ }
+
+ @Test
+ void configuredAssignorIsUsed() {
+ KafkaConfiguration configuration = new KafkaConfiguration();
+
configuration.setPartitionAssignor(CooperativeStickyAssignor.class.getName());
+
+ Properties props = configuration.createConsumerProperties();
+
+ assertEquals(CooperativeStickyAssignor.class.getName(),
+
props.get(ConsumerConfig.PARTITION_ASSIGNMENT_STRATEGY_CONFIG));
+ }
+
+ @Test
+ void configuredAssignorIsNotUsedWithConsumerGroupProtocol() {
+ KafkaConfiguration configuration = new KafkaConfiguration();
+
configuration.setPartitionAssignor(CooperativeStickyAssignor.class.getName());
+ configuration.setGroupProtocol("consumer");
+
+ Properties props = configuration.createConsumerProperties();
+
+
assertFalse(props.containsKey(ConsumerConfig.PARTITION_ASSIGNMENT_STRATEGY_CONFIG));
+ }
+}
diff --git
a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/consumer/support/classic/ClassicRebalanceListenerTest.java
b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/consumer/support/classic/ClassicRebalanceListenerTest.java
new file mode 100644
index 000000000000..21c700d78252
--- /dev/null
+++
b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/consumer/support/classic/ClassicRebalanceListenerTest.java
@@ -0,0 +1,118 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kafka.consumer.support.classic;
+
+import java.util.List;
+import java.util.Set;
+
+import org.apache.camel.component.kafka.KafkaConfiguration;
+import org.apache.camel.component.kafka.SeekPolicy;
+import org.apache.camel.component.kafka.consumer.CommitManager;
+import org.apache.camel.support.processor.state.MemoryStateRepository;
+import org.apache.kafka.clients.consumer.Consumer;
+import org.apache.kafka.common.TopicPartition;
+import org.junit.jupiter.api.BeforeEach;
+import org.junit.jupiter.api.Test;
+
+import static org.mockito.ArgumentMatchers.anyCollection;
+import static org.mockito.ArgumentMatchers.anyLong;
+import static org.mockito.ArgumentMatchers.argThat;
+import static org.mockito.ArgumentMatchers.eq;
+import static org.mockito.Mockito.mock;
+import static org.mockito.Mockito.never;
+import static org.mockito.Mockito.verify;
+import static org.mockito.Mockito.when;
+
+/**
+ * With a cooperative assignor (CooperativeStickyAssignor) or the consumer
group protocol, a rebalance passes only the
+ * partitions it added to onPartitionsAssigned, and the consumer keeps reading
the partitions it already had. The seek
+ * of seekTo and offsetRepository must then only move the added partitions.
+ */
+class ClassicRebalanceListenerTest {
+
+ private static final TopicPartition KEPT = new TopicPartition("myTopic",
0);
+ private static final TopicPartition ADDED = new TopicPartition("myTopic",
1);
+
+ private Consumer<?, ?> consumer;
+ private KafkaConfiguration configuration;
+
+ @BeforeEach
+ void setUp() {
+ consumer = mock(Consumer.class);
+ // the consumer owns both partitions after the rebalance, but only
ADDED was assigned by it
+ when(consumer.assignment()).thenReturn(Set.of(KEPT, ADDED));
+ configuration = new KafkaConfiguration();
+ }
+
+ private ClassicRebalanceListener listener() {
+ return new ClassicRebalanceListener("thread-1", configuration,
mock(CommitManager.class), consumer);
+ }
+
+ @Test
+ void seekToBeginningOnlyMovesTheAssignedPartitions() {
+ configuration.setSeekTo(SeekPolicy.BEGINNING);
+
+ listener().onPartitionsAssigned(List.of(ADDED));
+
+ verify(consumer).seekToBeginning(List.of(ADDED));
+ verify(consumer, never()).seekToBeginning(Set.of(KEPT, ADDED));
+ }
+
+ @Test
+ void seekToEndOnlyMovesTheAssignedPartitions() {
+ configuration.setSeekTo(SeekPolicy.END);
+
+ listener().onPartitionsAssigned(List.of(ADDED));
+
+ verify(consumer).seekToEnd(List.of(ADDED));
+ verify(consumer, never()).seekToEnd(Set.of(KEPT, ADDED));
+ }
+
+ @Test
+ void rebalanceWithoutAddedPartitionsDoesNotSeek() {
+ configuration.setSeekTo(SeekPolicy.BEGINNING);
+
+ // a cooperative rebalance calls onPartitionsAssigned even when it
added no partition
+ listener().onPartitionsAssigned(List.of());
+
+ verify(consumer, never()).seekToBeginning(anyCollection());
+ }
+
+ @Test
+ void offsetRepositoryOnlyMovesTheAssignedPartitions() {
+ MemoryStateRepository repository = new MemoryStateRepository();
+
repository.setState(OffsetPartitionAssignmentAdapter.serializeOffsetKey(KEPT),
"10");
+
repository.setState(OffsetPartitionAssignmentAdapter.serializeOffsetKey(ADDED),
"20");
+ configuration.setOffsetRepository(repository);
+
+ listener().onPartitionsAssigned(List.of(ADDED));
+
+ verify(consumer).seek(ADDED, 21L);
+ verify(consumer, never()).seek(eq(KEPT), anyLong());
+ }
+
+ @Test
+ void eagerRebalanceMovesAllPartitions() {
+ configuration.setSeekTo(SeekPolicy.BEGINNING);
+
+ // an eager assignor (RangeAssignor) revokes everything and assigns
all the partitions of the consumer again
+ listener().onPartitionsAssigned(List.of(KEPT, ADDED));
+
+ // the same as before: every partition of the consumer is moved
+ verify(consumer).seekToBeginning(argThat(partitions ->
Set.copyOf(partitions).equals(Set.of(KEPT, ADDED))));
+ }
+}
diff --git
a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/consumer/support/resume/KafkaResumeAdapterTest.java
b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/consumer/support/resume/KafkaResumeAdapterTest.java
index 40732025b470..a31c35923b9d 100644
---
a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/consumer/support/resume/KafkaResumeAdapterTest.java
+++
b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/consumer/support/resume/KafkaResumeAdapterTest.java
@@ -19,6 +19,7 @@ package
org.apache.camel.component.kafka.consumer.support.resume;
import java.nio.ByteBuffer;
import java.util.HashMap;
import java.util.Iterator;
+import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.function.BiFunction;
@@ -130,6 +131,28 @@ class KafkaResumeAdapterTest {
assertEquals(42L, cache.get(tp));
}
+ @Test
+ void testResumeOnlySeeksTheGivenPartitions() {
+ // with a cooperative assignor (or the consumer group protocol) a
rebalance assigns only the added partitions:
+ // the partitions the consumer kept must not be moved back to the
stored offset
+ Consumer<?, ?> consumer = mock(Consumer.class);
+ adapter.setConsumer(consumer);
+
+ TopicPartition kept = new TopicPartition("myTopic", 0);
+ TopicPartition added = new TopicPartition("myTopic", 1);
+ cache.add(kept, 10L);
+ cache.add(added, 20L);
+ when(consumer.assignment()).thenReturn(Set.of(kept, added));
+
+ adapter.resume(List.of(added));
+
+ verify(consumer).seek(added, 20L);
+ verify(consumer, never()).seek(kept, 10L);
+ // both entries stay in the cache
+ assertEquals(10L, cache.get(kept));
+ assertEquals(20L, cache.get(added));
+ }
+
@Test
@SuppressWarnings("unchecked")
void testResumeSkipsSeekForUnassignedPartition() {
diff --git
a/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaConsumerIncrementalRebalanceSeekIT.java
b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaConsumerIncrementalRebalanceSeekIT.java
new file mode 100644
index 000000000000..20927fa50f5a
--- /dev/null
+++
b/components/camel-kafka/src/test/java/org/apache/camel/component/kafka/integration/KafkaConsumerIncrementalRebalanceSeekIT.java
@@ -0,0 +1,129 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.camel.component.kafka.integration;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.UUID;
+import java.util.concurrent.TimeUnit;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.kafka.clients.admin.NewTopic;
+import org.apache.kafka.clients.consumer.CooperativeStickyAssignor;
+import org.apache.kafka.clients.producer.KafkaProducer;
+import org.apache.kafka.clients.producer.ProducerRecord;
+import org.junit.jupiter.api.AfterEach;
+import org.junit.jupiter.api.Test;
+
+import static org.awaitility.Awaitility.await;
+import static org.junit.jupiter.api.Assertions.assertEquals;
+
+/**
+ * With a cooperative assignor or the consumer group protocol, a rebalance
assigns only the partitions it adds to a
+ * consumer, and the consumer keeps reading the other partitions from where it
is. seekTo must only move the added
+ * partitions: before CAMEL-27551 it moved the kept partitions back to the
beginning too, and their records were read
+ * again.
+ */
+class KafkaConsumerIncrementalRebalanceSeekIT extends BaseKafkaTestSupport {
+
+ private static final int RECORDS_PER_PARTITION = 5;
+ private static final String MARKER = "marker";
+
+ private String topic;
+ private KafkaProducer<String, String> producer;
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ // the routes are added by each test
+ return new RouteBuilder() {
+ @Override
+ public void configure() {
+ }
+ };
+ }
+
+ @AfterEach
+ void after() {
+ if (producer != null) {
+ producer.close();
+ }
+ if (topic != null) {
+ kafkaAdminClient.deleteTopics(List.of(topic));
+ }
+ }
+
+ @Test
+ void cooperativeAssignorKeepsThePositionOfTheKeptPartition() throws
Exception {
+ runScenario("partitionAssignor=" +
CooperativeStickyAssignor.class.getName());
+ }
+
+ @Test
+ void consumerGroupProtocolKeepsThePositionOfTheKeptPartition() throws
Exception {
+ runScenario("groupProtocol=consumer");
+ }
+
+ private void runScenario(String options) throws Exception {
+ String id = UUID.randomUUID().toString();
+ topic = "incremental-rebalance-" + id;
+ kafkaAdminClient.createTopics(List.of(new NewTopic(topic, 2, (short)
1))).all().get(30, TimeUnit.SECONDS);
+ producer = new KafkaProducer<>(getDefaultProperties());
+
+ for (int partition = 0; partition < 2; partition++) {
+ for (int i = 0; i < RECORDS_PER_PARTITION; i++) {
+ producer.send(new ProducerRecord<>(topic, partition, null, "p"
+ partition + "-" + i)).get();
+ }
+ }
+
+ CamelContext context = contextExtension.getContext();
+ String uri = "kafka:" + topic + "?groupId=group-" + id +
"&seekTo=BEGINNING&" + options;
+ context.addRoutes(new RouteBuilder() {
+ @Override
+ public void configure() {
+ from(uri).routeId("a-" + id).autoStartup(false).to("mock:a-" +
id);
+ from(uri).routeId("b-" + id).autoStartup(false).to("mock:b-" +
id);
+ }
+ });
+ MockEndpoint a = context.getEndpoint("mock:a-" + id,
MockEndpoint.class);
+ MockEndpoint b = context.getEndpoint("mock:b-" + id,
MockEndpoint.class);
+
+ // consumer a owns both partitions and reads all the records
+ context.getRouteController().startRoute("a-" + id);
+ await().atMost(30, TimeUnit.SECONDS).until(() ->
a.getReceivedCounter() >= 2 * RECORDS_PER_PARTITION);
+
+ // consumer b joins: the rebalance moves one partition to b, a keeps
the other one
+ context.getRouteController().startRoute("b-" + id);
+ await().atMost(60, TimeUnit.SECONDS).until(() ->
b.getReceivedCounter() >= RECORDS_PER_PARTITION);
+
+ // a marker at the end of each partition: once both are read, a has
read anything it was going to read again
+ for (int partition = 0; partition < 2; partition++) {
+ producer.send(new ProducerRecord<>(topic, partition, null,
MARKER)).get();
+ }
+ await().atMost(30, TimeUnit.SECONDS)
+ .until(() -> bodies(a).contains(MARKER) &&
bodies(b).contains(MARKER));
+
+ List<String> received = bodies(a);
+ assertEquals(2 * RECORDS_PER_PARTITION + 1, received.size(),
+ "consumer a must read each record of its kept partition once,
but received " + received);
+ assertEquals(received.size(), new HashSet<>(received).size(),
"duplicates in " + received);
+ }
+
+ private static List<String> bodies(MockEndpoint mock) {
+ return mock.getReceivedExchanges().stream().map(e ->
e.getMessage().getBody(String.class)).toList();
+ }
+}
diff --git
a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
index 82b1610df148..0af8b498cb0f 100644
--- a/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
+++ b/docs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_24.adoc
@@ -1305,6 +1305,24 @@ before each had a generated group of its own: routes
that consume the same topic
on each route that must receive every record. When both `groupId` and the
`group.id` property are set, `groupId` is
still used.
+=== camel-kafka - partitionAssignor uses the Kafka default
+
+The `partitionAssignor` option of the Kafka consumer no longer defaults to
+`org.apache.kafka.clients.consumer.RangeAssignor`. When it is not set, Camel
no longer sets
+`partition.assignment.strategy`, and the Kafka default applies:
`RangeAssignor` and `CooperativeStickyAssignor`, in
+that order. The partitions are still assigned by the `RangeAssignor`, also in
a consumer group where some members still
+run an older Camel version, so a rolling upgrade does not change the
assignment. To move the group to cooperative
+rebalancing afterwards, do one more rolling restart with `partitionAssignor`
set to
+`org.apache.kafka.clients.consumer.CooperativeStickyAssignor`. Set
`partitionAssignor` to
+`org.apache.kafka.clients.consumer.RangeAssignor` to keep the old setting.
+
+With a cooperative assignor, or with `groupProtocol=consumer`, a rebalance
assigns only the partitions it adds to a
+consumer, and the consumer keeps reading the other partitions from where it
was. `seekTo`, `offsetRepository` and a
+resume strategy now only move the partitions that a rebalance assigned.
Before, they also moved back the partitions
+that the consumer kept, which read their records again (`seekTo=BEGINNING`,
`offsetRepository`) or skipped records
+(`seekTo=END`). With an eager assignor such as `RangeAssignor` every rebalance
assigns all the partitions, so nothing
+changes there.
+
=== camel-kafka - Kafka 4.4 needs the Confluent serializers 8.4 or newer
Camel uses the Kafka 4.4 client, which moved
`org.apache.kafka.common.utils.ByteUtils` to
diff --git
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/KafkaComponentBuilderFactory.java
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/KafkaComponentBuilderFactory.java
index 6849ed9bce9a..6d54ef32caee 100644
---
a/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/KafkaComponentBuilderFactory.java
+++
b/dsl/camel-componentdsl/src/generated/java/org/apache/camel/builder/component/dsl/KafkaComponentBuilderFactory.java
@@ -954,15 +954,20 @@ public interface KafkaComponentBuilderFactory {
return this;
}
-
/**
- * The class name of the partition assignment strategy that the client
- * will use to distribute partition ownership amongst consumer
instances
- * when group management is used.
+ * The class names of the partition assignment strategies, ordered by
+ * preference, that the client will use to distribute partition
+ * ownership amongst consumer instances when group management is used.
+ * Multiple class names can be separated by comma. If not set, the
Kafka
+ * default is used: org.apache.kafka.clients.consumer.RangeAssignor and
+ * org.apache.kafka.clients.consumer.CooperativeStickyAssignor. This
+ * uses the RangeAssignor, but allows upgrading to the
+ * CooperativeStickyAssignor with a single rolling restart that removes
+ * the RangeAssignor from the list. This option is only used when
+ * groupProtocol is set to classic.
*
* The option is a: <code>java.lang.String</code> type.
*
- * Default: org.apache.kafka.clients.consumer.RangeAssignor
* Group: consumer
*
* @param partitionAssignor the value to set
diff --git
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/KafkaEndpointBuilderFactory.java
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/KafkaEndpointBuilderFactory.java
index fd60eb27ce6b..9fe6b7f9b0f1 100644
---
a/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/KafkaEndpointBuilderFactory.java
+++
b/dsl/camel-endpointdsl/src/generated/java/org/apache/camel/builder/endpoint/dsl/KafkaEndpointBuilderFactory.java
@@ -1472,13 +1472,19 @@ public interface KafkaEndpointBuilderFactory {
return this;
}
/**
- * The class name of the partition assignment strategy that the client
- * will use to distribute partition ownership amongst consumer
instances
- * when group management is used.
+ * The class names of the partition assignment strategies, ordered by
+ * preference, that the client will use to distribute partition
+ * ownership amongst consumer instances when group management is used.
+ * Multiple class names can be separated by comma. If not set, the
Kafka
+ * default is used: org.apache.kafka.clients.consumer.RangeAssignor and
+ * org.apache.kafka.clients.consumer.CooperativeStickyAssignor. This
+ * uses the RangeAssignor, but allows upgrading to the
+ * CooperativeStickyAssignor with a single rolling restart that removes
+ * the RangeAssignor from the list. This option is only used when
+ * groupProtocol is set to classic.
*
* The option is a: <code>java.lang.String</code> type.
*
- * Default: org.apache.kafka.clients.consumer.RangeAssignor
* Group: consumer
*
* @param partitionAssignor the value to set