Deprecated component cxfbean

274 views Asked by At

I am new to camel and I am migrating camel 2.x app to camel 3.x. I see that cxfbean scheme is deprecated and removed in version 3. I searched migration docs but I haven't seen anything related.

What is the best way to migrate where HelloService is just rest endpoint.

  <bean id="helloService" class="com.acme.HelloService"/>

  <camel:camelContext>
      <camel:route>
        <camel:from uri="jetty:http://localhost:9000?matchOnUriPrefix=true"></camel:from>
        <camel:to uri="cxfbean://helloService"></camel:to>
      </camel:route>
  </camel:camelContext> 
1

There are 1 answers

0
SebastianX On

I have the same problem, and I ended up with following steps

  1. use "bean:youServiceBeanName" instead,

  2. if your service has limited method, you can add ?methodname=xxx in the end if you want, like

    to( "bean:youServiceBeanName?methodname=xxx")

or if you have too many methods to map, you could set "CamelBeanMethodName" by processor of

    .process(exchange -> exchange.getIn().setHeader("CamelBeanMethodName", exchange.getIn().getHeader("operationName")))

then camel will invoke the bean's method for you

  1. about methods parameters, if camel can not map it correctly, you need to put @Header or @Body annotation on the rs service bean or interface method parameters,

  2. if you want to have your own json mapper, in spring simply create a @bean of type ObjectMapper, camel will use that for marshal and unmarshal

make reference to Bean::Apache camel 3