camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <claus.ib...@gmail.com>
Subject Re: How to make a copy an Exchange in a Route segment
Date Thu, 09 Jan 2014 16:07:10 GMT
You can use multicast

On Thu, Jan 9, 2014 at 4:09 PM, duncanto <tom_duncan@btinternet.com> wrote:
> Thanks for your suggestions .. which Ive tried but without success ...
>
> Ill clarify the problem with some noddy route code ..
>
> Cheers
>
>
> context.addRoutes(new RouteBuilder() {
>                         public void configure() throws Exception {
>
>                                 from("direct:start").setBody().constant("outer body")
>                                                 .setHeader("foo").constant("myfoo").
>                                                 setHeader("bar").constant("mybar")
>                                                 .choice()
>                                                    .when(header("foo").isEqualTo("myfoo"))
>                                                         // !!!! Is there a DSL definition
I can add here to create a copy
> of the message exchange
>                                                     // passed to the fooRoute and protect
the outer exchange  ????
>                                                    .removeHeaders("*", "foo")   // remove
all but keep the foo header
>                                                    .to("direct:fooRoute")
>                                                 .end()
>                                                 // dont want the bar header to be removed
at this point
>                                                 // dont want message body changed in
the fooRoute to be in scope here
>                                                 .log( "main flow - foo header is : ${header.foo}")
>                                                 .log( "main flow - bar header is : ${header.bar}")
>                                                 .log( "main flow - body is : ${body}")
>                                                 .log("finished");
>
>
>                                 from("direct:fooRoute")
>                                 .setBody().constant("foo body")
>                                 // ok :o) with bar header being removed
>                                 .log( "foo flow - foo header is : ${header.foo}")
>                                 .log( "foo flow - bar header is : ${header.bar}")
>                             .log( "foo flow - body is : ${body}")
>                                 .log("foo route finished")
>                                 // continue with further processing etc etc
>                                 .end();
>
>                         }
>                 });
>
>

You can use the mutlicast or content enricher to route to
direct:fooRoute, and then use an aggregation strategy where you just
use the oldExchange (= the original). eg in the aggreage method just
return the oldExchange

I am making this easier to do in next release using out of the box code.
https://issues.apache.org/jira/browse/CAMEL-7119



>
> --
> View this message in context: http://camel.465427.n5.nabble.com/How-to-make-a-copy-an-Exchange-in-a-Route-segment-tp5745772p5745792.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
Red Hat, Inc.
Email: cibsen@redhat.com
Twitter: davsclaus
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen
Make your Camel applications look hawt, try: http://hawt.io

Mime
View raw message