camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Sergey Beryozkin <sberyoz...@gmail.com>
Subject Re: Routing from servlet to CXF JAXRS via direct
Date Mon, 03 Jun 2013 20:09:56 GMT
Hi
On 03/06/13 20:53, Todd Orr wrote:
> I'm relatively new to Camel. I did research what I am attempting to do, but
> did not find much help.
>
> The goal is to take an existing standalone CXF rest service (with many
> service beans) and split it into multiple independent CXF rest services
> coordinated by Camel.
>
> As an initial step, I am attempting to front the existing service with
> Camel. So to be clear, at this stage, I only want to pass HTTP requests
> from Camel down to the CXF service. To this end I have run into multiple
> issues. I am currently unable to route the HTTP message received by Camel
> to the CXF service.
>
> My route:
>
>
>      <route>
>        <from
> uri="servlet:///rest?servletName=CamelAPI&amp;matchOnUriPrefix=true" />
>        <to uri="ref:message-logger" />
>        <setBody><simple>CamelHttpServletRequest</simple></setBody>
>        <to uri="ref:message-logger" />
>        <to uri="direct:api" />
>      </route>
>
> I have configured CXF using camel's transport factory using:
>
>    <bean
> class="org.apache.camel.component.cxf.transport.CamelTransportFactory">
>      <property name="bus" ref="cxf" />
>      <property name="camelContext" ref="camelContext" />
>      <property name="checkException" value="true" />
>      <property name="transportIds">
>        <list>
>          <value>http://cxf.apache.org/transports/camel</value>
>        </list>
>      </property>
>    </bean>
>
> This was required to get around some earlier issues I ran into. My CXF
> service is configured like:
>
>
>    <jaxrs:server id="restService" address="direct:api">
>      <jaxrs:serviceBeans>
>    ...
>
> Startup is fine. On attempting to hit the servlet via RESTClient I can see
> the message I passed in logged correctly. However, the CXF service cannot
> receive the message. The error is:
>
> No consumers available on endpoint: Endpoint[direct://api] to process:
> Exchange ...
>
> Any help is greatly appreciated.
>
This is an interesting idea, to try to use a 'direct' URI scheme as 
jaxrs server endpoint. I don't think it works right now, and I'm not 
sure what has to be done yet, but definitely worth investigating...
In meantime, using Camel transport scheme will do, try something like this:

<jaxrs:server id="hello_rest" 
address="camel://direct:HelloWorldRestServerEndpoint">
<!-- usual declarations here -->
</jaxrs:server>

     <!-- Camel routes from addresses on the servlet to rest and jaxws 
servers -->
     <camelContext id="camelContext" 
xmlns="http://camel.apache.org/schema/spring" trace="false">
         <route>
             <from uri="servlet:///HelloWorld?matchOnUriPrefix=true"/>
             <to uri="direct:HelloWorldRestServerEndpoint"/>
         </route>
     </camelContext>


HTH, Sergey
> T
>


Mime
View raw message