camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Willem Jiang <willem.ji...@gmail.com>
Subject Re: Processor explanation
Date Tue, 20 Jul 2010 08:46:41 GMT

If we can map the CXF operation name to the bean's method, then camel 
can invoke the bean as you want.

You can use CXF directly by setting the implementor with your bean.

If you already has the response, I don't know what you want to do next 
with the camel route. Can you tell me your user story?

Willem
----------------------------------
  Apache Camel, Apache CXF committer
  Open Source Integration http://www.fusesource.com
  Blog http://willemjiang.blogspot.com
  Tiwtter http://twitter.com/willemjiang


Bruno Dusausoy wrote:
> Hi,
> 
> I'm a little confused by the use of a processor when consuming message (in
> POJO mode) from a CXF endpoint.
> Basically, what I want to do is consuming messages from the latter : just
> knowing what the operation is and do some processing depending on it,
> returning the result to the caller (the producer) and then let the message
> continue its journey through the routes I've configured.
> 
> public class CareerRouteBuilder extends SpringRouteBuilder {
> 
>     // ...
>     @Override
>     public void configure() throws Exception {
>         
>         from("cxf://bean:myService").process(new Processor() {
>             public void process(Exchange exchange) throws Exception {
>                 String operation =
> exchange.getIn().getHeader(CxfConstants.OPERATION_NAME, String.class);
>                 /*
>                  * Maybe I could use reflection on a bean implementing the
> interface 
>                  * automatically generated by CXF's codegen-maven-plugin
> instead of using "if" statements.
>                  */
>                 if (operation.equals("SomeOperation")) {
>                     MyResponse res =
> someBean.process(exchange.getIn().getBody(SomeClazz.class);
>                     exchange.getOut().setBody(res);
>                 } else if (operation.equals("AnotherOperation")) {
>                     // ...
>                 } else {
>                     // ...
>                 }
>             }
>         });
>     }
> }
> 
> It works fine, but is it the best way to do what I want ?
> Of course I could also use CXF directly and then route manually the result
> to the desired endpoint.
> But it would definitely be nicer if I could directly use a bean to process
> the desired operation.
> I've read the CXF Component documentation but haven't found anything like
> this.
> Am I missing something ?
> 
> Regards.


Mime
View raw message