You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2024/10/03 11:21:54 UTC
(camel) 02/02: CAMEL-21309: camel-cxf - Force using sync client when using tracing/opentelemetry as otherwise spans are not working correctly.
This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch camel-4.4.x
in repository https://gitbox.apache.org/repos/asf/camel.git
commit ede679943e9ee2f281f3ce1551aeda636ba79d80
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Thu Oct 3 13:21:40 2024 +0200
CAMEL-21309: camel-cxf - Force using sync client when using tracing/opentelemetry as otherwise spans are not working correctly.
---
.../java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java | 7 +++----
.../java/org/apache/camel/component/cxf/jaxws/CxfProducer.java | 7 +++----
2 files changed, 6 insertions(+), 8 deletions(-)
diff --git a/components/camel-cxf/camel-cxf-rest/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java b/components/camel-cxf/camel-cxf-rest/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
index aa22b81a0cf..200f403312b 100644
--- a/components/camel-cxf/camel-cxf-rest/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
+++ b/components/camel-cxf/camel-cxf-rest/src/main/java/org/apache/camel/component/cxf/jaxrs/CxfRsProducer.java
@@ -42,7 +42,6 @@ import jakarta.ws.rs.core.Response;
import org.apache.camel.AsyncCallback;
import org.apache.camel.CamelExchangeException;
import org.apache.camel.Exchange;
-import org.apache.camel.ExchangePropertyKey;
import org.apache.camel.Message;
import org.apache.camel.component.cxf.common.CxfOperationException;
import org.apache.camel.component.cxf.common.message.CxfConstants;
@@ -60,8 +59,6 @@ import org.apache.cxf.jaxrs.client.WebClient;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.apache.camel.Exchange.ACTIVE_SPAN;
-
/**
* CxfRsProducer binds a Camel exchange to a CXF exchange, acts as a CXF JAXRS client, it will turn the normal Object
* invocation to a RESTful request according to resource annotation. Any response will be bound to Camel exchange.
@@ -70,6 +67,8 @@ public class CxfRsProducer extends DefaultAsyncProducer {
private static final Logger LOG = LoggerFactory.getLogger(CxfRsProducer.class);
+ private static final String ACTIVE_SPAN_PROPERTY = "OpenTracing.activeSpan";
+
private boolean throwException;
// using a cache of factory beans instead of setting the address of a single cfb
@@ -112,7 +111,7 @@ public class CxfRsProducer extends DefaultAsyncProducer {
@Override
public boolean process(Exchange exchange, AsyncCallback callback) {
// if using camel-tracer then execute this synchronously due to CXF-9063
- if (exchange.getProperty(ExchangePropertyKey.ACTIVE_SPAN) != null) {
+ if (exchange.getProperty(ACTIVE_SPAN_PROPERTY) != null) {
try {
process(exchange);
} catch (Exception e) {
diff --git a/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfProducer.java b/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfProducer.java
index 036985148b6..a770d232bed 100644
--- a/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfProducer.java
+++ b/components/camel-cxf/camel-cxf-soap/src/main/java/org/apache/camel/component/cxf/jaxws/CxfProducer.java
@@ -32,7 +32,6 @@ import javax.xml.namespace.QName;
import org.apache.camel.AsyncCallback;
import org.apache.camel.Exchange;
-import org.apache.camel.ExchangePropertyKey;
import org.apache.camel.RuntimeCamelException;
import org.apache.camel.component.cxf.common.CxfPayload;
import org.apache.camel.component.cxf.common.DataFormat;
@@ -52,8 +51,6 @@ import org.apache.cxf.service.model.BindingOperationInfo;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
-import static org.apache.camel.Exchange.ACTIVE_SPAN;
-
/**
* CxfProducer binds a Camel exchange to a CXF exchange, acts as a CXF client, and sends the request to a CXF to a
* server. Any response will be bound to Camel exchange.
@@ -62,6 +59,8 @@ public class CxfProducer extends DefaultAsyncProducer {
private static final Logger LOG = LoggerFactory.getLogger(CxfProducer.class);
+ private static final String ACTIVE_SPAN_PROPERTY = "OpenTracing.activeSpan";
+
private Client client;
private CxfEndpoint endpoint;
@@ -103,7 +102,7 @@ public class CxfProducer extends DefaultAsyncProducer {
@Override
public boolean process(Exchange camelExchange, AsyncCallback callback) {
// if using camel-tracer then execute this synchronously due to CXF-9063
- if (camelExchange.getProperty(ExchangePropertyKey.ACTIVE_SPAN) != null) {
+ if (camelExchange.getProperty(ACTIVE_SPAN_PROPERTY) != null) {
try {
process(camelExchange);
} catch (Exception e) {