You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Hervé BARRAULT <he...@gmail.com> on 2012/04/18 10:46:18 UTC

Mix InOnly and Request-Reply in one Route

Hi,

I have a WSDL with both Request-Reponse and One-Way operations for the same
binding.

When using CXF i have for each "operation" a method to implement (so code
for OneWay - RequestReply is easy to split).

When using CAMEL/CXF, i have a single route to handle both In-Only and
In-Out.

Previously i had ONLY inOnly messages so a simple route with a simple
myProcessor like :

from("cxf:bean:myEndpoint")
        .process(myProcessor)
        .to("activemq:queue:myQueue");

was enough.



But with mix of InOnly InOut, myProcessor should become more complex and i
will add at least one another processor to handle response and errors.

I would use a Message Router based on operation :

from("cxf:bean:myEndpoint")
            .choice()
                .when(header("operation").isEqualTo("operation1"))
                    .to(processor1)
                .when(header("operation").isEqualTo("operation2"))
                    .to(processor2)
                .otherwise()
                    .to(processor3);

But if i have a lot of operations, the route will be a nightmare.

What is the best way to mix both request/Reply and InOnly (in order to ease
understanding and coding) with Camel ?

Regards

Hervé

Re: Mix InOnly and Request-Reply in one Route

Posted by Claus Ibsen <cl...@gmail.com>.
On Wed, Apr 18, 2012 at 10:46 AM, Hervé BARRAULT
<he...@gmail.com> wrote:
> Hi,
>
> I have a WSDL with both Request-Reponse and One-Way operations for the same
> binding.
>
> When using CXF i have for each "operation" a method to implement (so code
> for OneWay - RequestReply is easy to split).
>
> When using CAMEL/CXF, i have a single route to handle both In-Only and
> In-Out.
>
> Previously i had ONLY inOnly messages so a simple route with a simple
> myProcessor like :
>
> from("cxf:bean:myEndpoint")
>        .process(myProcessor)
>        .to("activemq:queue:myQueue");
>
> was enough.
>
>
>
> But with mix of InOnly InOut, myProcessor should become more complex and i
> will add at least one another processor to handle response and errors.
>
> I would use a Message Router based on operation :
>
> from("cxf:bean:myEndpoint")
>            .choice()
>                .when(header("operation").isEqualTo("operation1"))
>                    .to(processor1)
>                .when(header("operation").isEqualTo("operation2"))
>                    .to(processor2)
>                .otherwise()
>                    .to(processor3);
>
> But if i have a lot of operations, the route will be a nightmare.
>
> What is the best way to mix both request/Reply and InOnly (in order to ease
> understanding and coding) with Camel ?
>

Maybe use a bean that has a method name that matches the SOAP
operation name, and invoke that

from("cxf:bean:myEndpoint")
.recipientList(simple("bean:myBean?method=${header.operation}"));

See the dynamic to FAQ
http://camel.apache.org/how-do-i-use-dynamic-uri-in-to.html


> Regards
>
> Hervé



-- 
Claus Ibsen
-----------------
CamelOne 2012 Conference, May 15-16, 2012: http://camelone.com
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.blogspot.com/
Author of Camel in Action: http://www.manning.com/ibsen/