Skip to content

Fix rest-cxf-opentelemetry example: use CamelCxfOperationName, migrate to camel-opentelemetry2 - #209

Open
Croway wants to merge 1 commit into
apache:mainfrom
Croway:fix-rest-cxf-otel-operation-name
Open

Fix rest-cxf-opentelemetry example: use CamelCxfOperationName, migrate to camel-opentelemetry2#209
Croway wants to merge 1 commit into
apache:mainfrom
Croway:fix-rest-cxf-otel-operation-name

Conversation

@Croway

@Croway Croway commented Sep 4, 2026

Copy link
Copy Markdown
Contributor

Summary

Same underlying bug as #206 (rest-cxf), replicated across all 3 services in this example:

  • random, even, and odd CamelRouters each dispatched on ${header.operationName}, a header CXF-RS never sets. DefaultCxfRsBinding actually populates CamelCxfOperationName for every cxfrs request regardless of binding style, so the header resolved empty and every REST call hit bean:...ServiceImpl?method= with a blank method name, throwing MethodNotFoundException (500).
  • Fixed by routing on ${header.CamelCxfOperationName} in all three modules (kept the existing toD dispatch style already used here, consistent with Fix rest-cxf example: use CamelCxfOperationName for dynamic bean dispatch #206).

Additionally, camel-opentelemetry (v1) logs a deprecation warning suggesting camel-opentelemetry2. Migrated all 3 services:

  • Swapped camel-opentelemetry-startercamel-opentelemetry2-starter in rest-cxf-opentelemetry/pom.xml.
  • Swapped @CamelOpenTelemetry@CamelOpenTelemetry2 (and the corresponding import) in each service's Application class.
  • This matches the convention already used by the sibling opentelemetry/*Booking examples in this repo, which are already on camel-opentelemetry2-starter.

The OTel javaagent (2.19.0) attaches fine on JDK 25 here, confirmed while testing.

Test plan

  • mvn -pl rest-cxf-opentelemetry,rest-cxf-opentelemetry/rest-cxf-otel-common,rest-cxf-opentelemetry/rest-cxf-otel-random,rest-cxf-opentelemetry/rest-cxf-otel-even,rest-cxf-opentelemetry/rest-cxf-otel-odd -am package
  • Built the OTel javaagent via -Potel-agent, started docker-compose (minio, otel-collector, jaeger), pre-created the evenodd minio bucket, and ran all 3 services (random:8080, even:8081, odd:8082) with the javaagent attached
  • POST /services/api/play/5 on random → 200, correct even/odd split result (exercises the full random → even/odd → register → minio round trip)
  • POST /services/api/check on even and odd directly → 200
  • GET /services/api/generate on random → 200
  • Logs confirm Opentelemetry2 enabled, no deprecation warning, no exceptions

🤖 Generated with Claude Code

…grate to camel-opentelemetry2

Same bug as the plain rest-cxf example, replicated across all 3 services
(random/even/odd): CamelRouter routed on ${header.operationName}, which
CXF-RS never sets, instead of ${header.CamelCxfOperationName} which
DefaultCxfRsBinding actually populates. Every REST call hit
MethodNotFoundException (500).

Also migrate off camel-opentelemetry (v1), which logs a deprecation
warning, to camel-opentelemetry2 - swap the starter artifactId and the
@CamelOpenTelemetry annotation for @CamelOpenTelemetry2 in each service's
Application class, matching the convention already used by the sibling
opentelemetry/*Booking examples.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01JvQJNT1UYzqUm5HQtkL6Nu
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant