CAMEL-23584: camel-kafka - align Exchange header constant names with Camel naming convention#23602
Conversation
…Camel naming convention
Renames the Exchange header string values in KafkaConstants from the
non-Camel-prefixed "kafka.*" namespace (kafka.PARTITION_KEY,
kafka.PARTITION, kafka.KEY, kafka.TOPIC, kafka.OVERRIDE_TOPIC,
kafka.OFFSET, kafka.HEADERS, kafka.LAST_RECORD_BEFORE_COMMIT,
kafka.LAST_POLL_RECORD, kafka.TIMESTAMP, kafka.OVERRIDE_TIMESTAMP,
kafka.RECORD_META) to the project-wide "CamelKafka*" PascalCase
convention used across the rest of the Camel component catalog,
matching the pattern established in CAMEL-23576 (camel-jira),
CAMEL-23574 (camel-dns), CAMEL-23575 (camel-mongodb-gridfs),
CAMEL-23578 (camel-web3j), CAMEL-23579 (camel-pdf), CAMEL-23580
(camel-openstack), CAMEL-23581 (camel-elasticsearch /
camel-opensearch), CAMEL-23582 (camel-github2), CAMEL-23585
(camel-arangodb), CAMEL-23587 (camel-jt400), CAMEL-23588
(camel-undertow), CAMEL-23590 (camel-milo), CAMEL-23592 (camel-shiro),
CAMEL-23597 (camel-solr), and CAMEL-23629 (camel-irc).
The Java field names (PARTITION_KEY, PARTITION, KEY, TOPIC,
OVERRIDE_TOPIC, OFFSET, HEADERS, LAST_RECORD_BEFORE_COMMIT,
LAST_POLL_RECORD, TIMESTAMP, OVERRIDE_TIMESTAMP, KAFKA_RECORD_META)
are unchanged so routes and code referencing the constants
symbolically continue to work without changes. Routes that set or
read the headers using the literal "kafka.*" string values must be
updated to use the new "CamelKafka*" values; the 4.21 upgrade guide
documents this as a "potential breaking change" with the rename
table and a worked example. KafkaConstants.MANUAL_COMMIT was already
Camel-prefixed (CamelKafkaManualCommit) and is unchanged. The
non-header constants in the class (KAFKA_DEFAULT_ENCODER,
KAFKA_STRING_ENCODER, KAFKA_DEFAULT_SERIALIZER,
KAFKA_DEFAULT_DESERIALIZER, PARTITIONER_RANGE_ASSIGNOR,
KAFKA_SUBSCRIBE_ADAPTER) are not Exchange headers and are unchanged.
Updates the bundled Kafka Connect-style transformers under
org.apache.camel.component.kafka.transform (RegexRouter,
TimestampRouter, MessageTimestampRouter, ValueToKey) and the
KafkaHeaderDeserializer to use the symbolic KafkaConstants
references instead of literal "kafka.*" string values. Updates the
KafkaProducerTest, RegexRouterTest, and KafkaConsumerFullIT tests
that referenced the literal "kafka.*" string values to use the
KafkaConstants symbolic references instead. Updates the
kafka-component.adoc consumer examples that use Simple expressions
to read these headers (${headers[CamelKafkaTopic]} etc.).
Keeps the local copies of the constants in
org.apache.camel.tracing.decorators.KafkaSpanDecorator (deprecated
since 4.19.0) and org.apache.camel.telemetry.decorators.KafkaSpanDecorator
in sync with the new values so that Kafka span tagging continues to
work for routes that have migrated to the new header names. Updates
the camel-opentelemetry2 mock Kafka producer and the SpanKindTest
that exercises the inherited decorator behavior to use the new
header names accordingly.
Regenerates the camel-catalog and component-local catalog artifacts
for camel-kafka, the auto-generated KafkaEndpointBuilderFactory
endpoint DSL header accessors (method names kafkaPartitionKey(),
kafkaTopic(), kafkaOverrideTopic(), etc. are unchanged - only the
returned string value reflects the new convention), the
ImportantHeaderUtils and important-headers.json that mirror the
@metadata(important = true) header values, and adds the
"camel-kafka - potential breaking change" entry to the 4.21 upgrade
guide.
Tracker: CAMEL-23577
Reported by Claude Code on behalf of Andrea Cosentino
Signed-off-by: Andrea Cosentino <ancosen@gmail.com>
|
🌟 Thank you for your contribution to the Apache Camel project! 🌟 🐫 Apache Camel Committers, please review the following items:
|
|
🧪 CI tested the following changed modules:
Build reactor — dependencies compiled but only changed modules were tested (8 modules)
|
gnodet
left a comment
There was a problem hiding this comment.
Standard header rename for camel-kafka: kafka.PARTITION_KEY → CamelKafkaPartitionKey, kafka.KEY → CamelKafkaKey, etc. Follows the established Camel header naming convention. The bulk of the diff is generated catalog metadata, which is consistent with the constant renames.
Upgrade guide entry and documentation updates included.
LGTM.
Fully automatic review from Claude Code
…der constant names with Camel naming convention (#23602) Backport of #23602 (CAMEL-23584) to camel-4.18.x. Renames the Exchange header string values in KafkaConstants from the non-Camel-prefixed "kafka.*" namespace to the project-wide "CamelKafka*" PascalCase convention. Java field names are unchanged (symbolic references keep working); routes hard-coding the literal "kafka.*" header strings must move to the new "CamelKafka*" values. Keeps the bundled transforms, the KafkaHeaderDeserializer, the camel-tracing / camel-telemetry KafkaSpanDecorator copies, and the camel-opentelemetry2 mock/SpanKindTest in sync, and regenerates the catalog, endpoint DSL, and important-headers artifacts. The upgrade-guide entry is added on main (per the backport upgrade-guide policy). Tracker: CAMEL-23577 Closes #23629
…der constant names with Camel naming convention (#23602) Backport of #23602 (CAMEL-23584) to camel-4.14.x. Renames the Exchange header string values in KafkaConstants from the non-Camel-prefixed "kafka.*" namespace to the project-wide "CamelKafka*" PascalCase convention. Java field names are unchanged (symbolic references keep working); routes hard-coding the literal "kafka.*" header strings must move to the new "CamelKafka*" values. Only the string values were changed on this branch (4.14.x KafkaConstants differs from main and its structure is otherwise preserved). Keeps the bundled transforms, the KafkaHeaderDeserializer, and the camel-tracing / camel-telemetry KafkaSpanDecorator copies in sync, and regenerates the catalog and endpoint DSL artifacts. The camel-opentelemetry2 test infra, core ImportantHeaderUtils, and important-headers.json do not exist on this branch. The upgrade-guide entry is added on main (per the backport upgrade-guide policy). Tracker: CAMEL-23577 Closes #23632
Summary
Renames the Exchange header string values in
KafkaConstantsfrom the non-Camel-prefixedkafka.*namespace to the project-wideCamelKafka*PascalCase convention, completing the camel-kafka sub-task under the CAMEL-23577 umbrella header-naming-convention sweep.Rename table
KafkaConstants.PARTITION_KEYkafka.PARTITION_KEYCamelKafkaPartitionKeyKafkaConstants.PARTITIONkafka.PARTITIONCamelKafkaPartitionKafkaConstants.KEYkafka.KEYCamelKafkaKeyKafkaConstants.TOPICkafka.TOPICCamelKafkaTopicKafkaConstants.OVERRIDE_TOPICkafka.OVERRIDE_TOPICCamelKafkaOverrideTopicKafkaConstants.OFFSETkafka.OFFSETCamelKafkaOffsetKafkaConstants.HEADERSkafka.HEADERSCamelKafkaHeadersKafkaConstants.LAST_RECORD_BEFORE_COMMITkafka.LAST_RECORD_BEFORE_COMMITCamelKafkaLastRecordBeforeCommitKafkaConstants.LAST_POLL_RECORDkafka.LAST_POLL_RECORDCamelKafkaLastPollRecordKafkaConstants.TIMESTAMPkafka.TIMESTAMPCamelKafkaTimestampKafkaConstants.OVERRIDE_TIMESTAMPkafka.OVERRIDE_TIMESTAMPCamelKafkaOverrideTimestampKafkaConstants.KAFKA_RECORD_METAkafka.RECORD_METACamelKafkaRecordMetaKafkaConstants.MANUAL_COMMITwas already Camel-prefixed (CamelKafkaManualCommit) and is unchanged. The non-header constants in the class (KAFKA_DEFAULT_ENCODER,KAFKA_STRING_ENCODER,KAFKA_DEFAULT_SERIALIZER,KAFKA_DEFAULT_DESERIALIZER,PARTITIONER_RANGE_ASSIGNOR,KAFKA_SUBSCRIBE_ADAPTER) are not Exchange headers and are unchanged.Backwards-compatibility
setHeader(KafkaConstants.OVERRIDE_TOPIC, ...)) continue to work without changes.kafka.*strings (e.g.setHeader("kafka.OVERRIDE_TOPIC", ...)or Simple expressions like${headers[kafka.TOPIC]}) must be updated to the newCamelKafka*values.KafkaEndpointBuilderFactory$KafkaHeaderNameBuilder(e.g.kafkaOverrideTopic(),kafkaTopic(),kafkaPartitionKey()) keep their method names; only the returned string value reflects the new convention.Cross-module updates
KafkaHeaderDeserializerand the bundled Kafka Connect-style transformers (RegexRouter,TimestampRouter,MessageTimestampRouter,ValueToKey) now use the symbolicKafkaConstantsreferences instead of literal"kafka.*"strings.org.apache.camel.tracing.decorators.KafkaSpanDecorator(deprecated since 4.19.0) andorg.apache.camel.telemetry.decorators.KafkaSpanDecoratorare kept in sync with the new values so Kafka span tagging continues to work for routes that have migrated to the new header names.SpanKindTestare updated to use the new header names.KafkaProducerTest,RegexRouterTest, andKafkaConsumerFullITare updated to use theKafkaConstantssymbolic references.kafka-component.adocthat use Simple expressions to read these headers (${headers[CamelKafkaTopic]}etc.) are updated.Regenerated artifacts
components/camel-kafkacomponent catalog (kafka.json)catalog/camel-catalogmirror andimportant-headers.jsoncore/camel-util/ImportantHeaderUtils.javadsl/camel-endpointdsl/.../KafkaEndpointBuilderFactory.javaPlus the new
camel-kafka - potential breaking changeentry indocs/user-manual/modules/ROOT/pages/camel-4x-upgrade-guide-4_21.adoc.Sibling sub-tasks under CAMEL-23577
This sub-task follows the pattern established in CAMEL-23576 (camel-jira), CAMEL-23574 (camel-dns), CAMEL-23575 (camel-mongodb-gridfs), CAMEL-23578 (camel-web3j), CAMEL-23579 (camel-pdf), CAMEL-23580 (camel-openstack), CAMEL-23581 (camel-elasticsearch / camel-opensearch), CAMEL-23582 (camel-github2), CAMEL-23585 (camel-arangodb), CAMEL-23587 (camel-jt400), CAMEL-23588 (camel-undertow), CAMEL-23590 (camel-milo), CAMEL-23592 (camel-shiro), CAMEL-23597 (camel-solr), and CAMEL-23629 (camel-irc).
Test plan
mvn installincomponents/camel-kafka— passes (unit tests + catalog regen)mvn testincomponents/camel-tracing— passesmvn testincomponents/camel-telemetry— passesmvn testincomponents/camel-opentelemetry2— passes (aftermvn installof upstream changes — SpanKindTest correctly exercises the renamed headers through the camel-telemetry KafkaSpanDecorator)mvn clean install -DskipTestsfrom root — passes, all downstream catalog / DSL / important-headers generators regenerate cleanlyReported by Claude Code on behalf of Andrea Cosentino