Skip to content

CAMEL-23584: camel-kafka - align Exchange header constant names with Camel naming convention#23602

Merged
oscerd merged 1 commit into
apache:mainfrom
oscerd:fix/CAMEL-23584
May 29, 2026
Merged

CAMEL-23584: camel-kafka - align Exchange header constant names with Camel naming convention#23602
oscerd merged 1 commit into
apache:mainfrom
oscerd:fix/CAMEL-23584

Conversation

@oscerd
Copy link
Copy Markdown
Contributor

@oscerd oscerd commented May 28, 2026

Summary

Renames the Exchange header string values in KafkaConstants from the non-Camel-prefixed kafka.* namespace to the project-wide CamelKafka* PascalCase convention, completing the camel-kafka sub-task under the CAMEL-23577 umbrella header-naming-convention sweep.

Rename table

Constant Previous value New value
KafkaConstants.PARTITION_KEY kafka.PARTITION_KEY CamelKafkaPartitionKey
KafkaConstants.PARTITION kafka.PARTITION CamelKafkaPartition
KafkaConstants.KEY kafka.KEY CamelKafkaKey
KafkaConstants.TOPIC kafka.TOPIC CamelKafkaTopic
KafkaConstants.OVERRIDE_TOPIC kafka.OVERRIDE_TOPIC CamelKafkaOverrideTopic
KafkaConstants.OFFSET kafka.OFFSET CamelKafkaOffset
KafkaConstants.HEADERS kafka.HEADERS CamelKafkaHeaders
KafkaConstants.LAST_RECORD_BEFORE_COMMIT kafka.LAST_RECORD_BEFORE_COMMIT CamelKafkaLastRecordBeforeCommit
KafkaConstants.LAST_POLL_RECORD kafka.LAST_POLL_RECORD CamelKafkaLastPollRecord
KafkaConstants.TIMESTAMP kafka.TIMESTAMP CamelKafkaTimestamp
KafkaConstants.OVERRIDE_TIMESTAMP kafka.OVERRIDE_TIMESTAMP CamelKafkaOverrideTimestamp
KafkaConstants.KAFKA_RECORD_META kafka.RECORD_META CamelKafkaRecordMeta

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.

Backwards-compatibility

  • Java field names are unchanged. Routes that reference the constants symbolically (setHeader(KafkaConstants.OVERRIDE_TOPIC, ...)) continue to work without changes.
  • Routes hard-coding the literal kafka.* strings (e.g. setHeader("kafka.OVERRIDE_TOPIC", ...) or Simple expressions like ${headers[kafka.TOPIC]}) must be updated to the new CamelKafka* values.
  • The 4.21 upgrade guide entry is marked as a "potential breaking change" with the full rename table and a worked example, given the wider installed base of camel-kafka than the niche sibling components in the sweep.
  • The Endpoint DSL header accessor method names on KafkaEndpointBuilderFactory$KafkaHeaderNameBuilder (e.g. kafkaOverrideTopic(), kafkaTopic(), kafkaPartitionKey()) keep their method names; only the returned string value reflects the new convention.

Cross-module updates

  • KafkaHeaderDeserializer and the bundled Kafka Connect-style transformers (RegexRouter, TimestampRouter, MessageTimestampRouter, ValueToKey) now use the symbolic KafkaConstants references instead of literal "kafka.*" strings.
  • 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 are kept in sync with the new values so Kafka span tagging continues to work for routes that have migrated to the new header names.
  • The camel-opentelemetry2 mock Kafka producer and SpanKindTest are updated to use the new header names.
  • KafkaProducerTest, RegexRouterTest, and KafkaConsumerFullIT are updated to use the KafkaConstants symbolic references.
  • The consumer examples in kafka-component.adoc that use Simple expressions to read these headers (${headers[CamelKafkaTopic]} etc.) are updated.

Regenerated artifacts

  • components/camel-kafka component catalog (kafka.json)
  • Project-wide catalog/camel-catalog mirror and important-headers.json
  • core/camel-util/ImportantHeaderUtils.java
  • dsl/camel-endpointdsl/.../KafkaEndpointBuilderFactory.java

Plus the new camel-kafka - potential breaking change entry in docs/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 install in components/camel-kafka — passes (unit tests + catalog regen)
  • mvn test in components/camel-tracing — passes
  • mvn test in components/camel-telemetry — passes
  • mvn test in components/camel-opentelemetry2 — passes (after mvn install of upstream changes — SpanKindTest correctly exercises the renamed headers through the camel-telemetry KafkaSpanDecorator)
  • Full reactor mvn clean install -DskipTests from root — passes, all downstream catalog / DSL / important-headers generators regenerate cleanly

Reported by Claude Code on behalf of Andrea Cosentino

…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>
@oscerd oscerd requested review from davsclaus and gnodet May 28, 2026 14:35
@github-actions
Copy link
Copy Markdown
Contributor

🌟 Thank you for your contribution to the Apache Camel project! 🌟
🤖 CI automation will test this PR automatically.

🐫 Apache Camel Committers, please review the following items:

  • First-time contributors require MANUAL approval for the GitHub Actions to run
  • You can use the command /component-test (camel-)component-name1 (camel-)component-name2.. to request a test from the test bot although they are normally detected and executed by CI.
  • You can label PRs using skip-tests and test-dependents to fine-tune the checks executed by this PR.
  • Build and test logs are available in the summary page. Only Apache Camel committers have access to the summary.

⚠️ Be careful when sharing logs. Review their contents before sharing them publicly.

@github-actions
Copy link
Copy Markdown
Contributor

🧪 CI tested the following changed modules:

  • catalog/camel-catalog
  • components/camel-kafka
  • components/camel-opentelemetry2
  • components/camel-telemetry
  • components/camel-tracing
  • core/camel-util
  • docs
  • dsl/camel-endpointdsl

ℹ️ Dependent modules were not tested because the total number of affected modules exceeded the threshold (50). Use the test-dependents label to force testing all dependents.

⚠️ Some tests are disabled on GitHub Actions (@DisabledIfSystemProperty(named = "ci.env.name")) and require manual verification:

  • components/camel-kafka: 2 test(s) disabled on GitHub Actions
Build reactor — dependencies compiled but only changed modules were tested (8 modules)
  • Camel :: Catalog :: Camel Catalog
  • Camel :: Common Telemetry
  • Camel :: Common Tracing (deprecated)
  • Camel :: Docs
  • Camel :: Endpoint DSL
  • Camel :: Kafka
  • Camel :: Opentelemetry 2
  • Camel :: Util

⚙️ View full build and test results

Copy link
Copy Markdown
Contributor

@gnodet gnodet left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Standard header rename for camel-kafka: kafka.PARTITION_KEYCamelKafkaPartitionKey, kafka.KEYCamelKafkaKey, 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

@oscerd oscerd merged commit f8914a2 into apache:main May 29, 2026
7 checks passed
@oscerd oscerd deleted the fix/CAMEL-23584 branch May 29, 2026 05:00
oscerd added a commit that referenced this pull request May 29, 2026
…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
oscerd added a commit that referenced this pull request May 29, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants