Can I use the same CXF endpoint as a producer in one Camel route and as a consumer in another Camel route?

Solution Verified - Updated -

Issue

We try to bridge two routes via a CXF endpoint, i.e. one route consumes from the CXF endpoint

<route id="route-1">
    <from uri="cxf:bean:myCXFEndpoint"/>
    …
</route>

and another route produces to this same endpoint

<route id="route-2" trace="true" streamCache="true">
    <from uri=“…” />
    …
    <camel:inOnly uri="cxf:bean:myCXFEndpoint”/>
</route>

As both routes are defined in the same CamelContext, they share the same CXF endpoint definition:

<cxf:cxfEndpoint id="myCXFEndpoint"
    address="jms:queue:Test.Queue?messageType=text&amp;exchangePattern=InOut&amp;relayHeaders=true"
    serviceClass="...">
    <cxf:properties>
        <entry key="dataFormat" value="PAYLOAD" />
    </cxf:properties>
</cxf:cxfEndpoint>

Is it possible to share the same CXF endpoint definition in both routes?

Trying the same on JBoss Fuse 6.2.1, it results in this NullPointerException when trying to invoke the CXF endpoint in the second route:

09:57:08,850 | WARN  | pool-42-thread-1 | PhaseInterceptorChain            | 74 - org.apache.cxf.cxf-core - 3.0.4.redhat-621084 | Interceptor for {http://test.com/service/GetPerson/V1}GetPersonPortTypeService has thrown exception, unwinding now
java.lang.NullPointerException
    at org.apache.camel.component.cxf.DefaultCxfBinding.getResponsePayloadList(DefaultCxfBinding.java:434)[207:org.apache.camel.camel-cxf:2.15.1.redhat-621103]
    at org.apache.camel.component.cxf.DefaultCxfBinding.populateCxfResponseFromExchange(DefaultCxfBinding.java:350)[207:org.apache.camel.camel-cxf:2.15.1.redhat-621103]
    at org.apache.camel.component.cxf.CxfConsumer$1.setResponseBack(CxfConsumer.java:216)[207:org.apache.camel.camel-cxf:2.15.1.redhat-621103]
    at org.apache.camel.component.cxf.CxfConsumer$1.syncInvoke(CxfConsumer.java:143)[207:org.apache.camel.camel-cxf:2.15.1.redhat-621103]
    at org.apache.camel.component.cxf.CxfConsumer$1.invoke(CxfConsumer.java:78)[207:org.apache.camel.camel-cxf:2.15.1.redhat-621103]
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor$1.run(ServiceInvokerInterceptor.java:59)[74:org.apache.cxf.cxf-core:3.0.4.redhat-621084]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511)[:1.8.0_91]
    at java.util.concurrent.FutureTask.run(FutureTask.java:266)[:1.8.0_91]
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor$2.run(ServiceInvokerInterceptor.java:126)[74:org.apache.cxf.cxf-core:3.0.4.redhat-621084]
    at org.apache.cxf.workqueue.SynchronousExecutor.execute(SynchronousExecutor.java:37)[74:org.apache.cxf.cxf-core:3.0.4.redhat-621084]
    at org.apache.cxf.interceptor.ServiceInvokerInterceptor.handleMessage(ServiceInvokerInterceptor.java:131)[74:org.apache.cxf.cxf-core:3.0.4.redhat-621084]
    at org.apache.cxf.phase.PhaseInterceptorChain.doIntercept(PhaseInterceptorChain.java:307)[74:org.apache.cxf.cxf-core:3.0.4.redhat-621084]
    at org.apache.cxf.transport.ChainInitiationObserver.onMessage(ChainInitiationObserver.java:121)[74:org.apache.cxf.cxf-core:3.0.4.redhat-621084]
    at org.apache.cxf.transport.jms.JMSDestination.onMessage(JMSDestination.java:233)[267:org.apache.cxf.cxf-rt-transports-jms:3.0.4.redhat-621084]
    at org.apache.cxf.transport.jms.util.PollingMessageListenerContainer$XAPoller.run(PollingMessageListenerContainer.java:117)[267:org.apache.cxf.cxf-rt-transports-jms:3.0.4.redhat-621084]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)[:1.8.0_91]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)[:1.8.0_91]
    at java.lang.Thread.run(Thread.java:745)[:1.8.0_91]

Environment

  • JBoss Fuse 6.2.1
  • Apache Camel 2.15.1
  • Apache CXF 3.0.4

Subscriber exclusive content

A Red Hat subscription provides unlimited access to our knowledgebase of over 48,000 articles and solutions.

Current Customers and Partners

Log in for full access

Log In
Close

Welcome! Check out the Getting Started with Red Hat page for quick tours and guides for common tasks.