Perfect. The difference is very well explained in the book. Thanks.
On Sun, Jun 1, 2014 at 8:40 AM, Claus Ibsen <[email protected]> wrote: > On Sat, May 31, 2014 at 2:18 PM, Max Bridgewater > <[email protected]> wrote: > > Hi Claus, > > > > Thanks for your feedback. Let me rewrite the two routes so we put the > issue > > of in vs. out aside. See below. After this change, the two routes still > > produce different results. Synchronization in route2 alters the final > > result of the route while it does not in route1. > > Yes read the documentation and javadoc, that would explain this in more > details. > > Or if you have a copy of Camel in Action, see page 313 on the top that > has a sidebar explaining the difference. > > > I did not expect this and I am having difficulty understanding why this > is > > the case. My question is thus, what is the meaning of one vs. the other > way > > of using onCompletion/Syncrhonization. Granted, when you change in.body > as > > opposed to out.body, neither of them changes the outcome of the route. > > > > > > Thanks. > > Max > > > > <route id="route1"> > > <from uri="restlet:/route1"/> > > <onCompletion onCompleteOnly="true"> > > <transform> > > <groovy>exchange.out.body="haha"</groovy> > > </transform> > > </onCompletion> > > <transform> > > <constant>hoho</constant> > > </transform> > > </route> > > > > <route id="route2"> > > <from uri="restlet:/route2"/> > > <transform> > > <groovy> > > exchange.getUnitOfWork().addSynchronization( > > new org.apache.camel.spi.Synchronization(){ > > public void > > onComplete(org.apache.camel.Exchange exchange){ > > exchange.out.body="haha" > > } > > public void > onFailure(org.apache.camel.Exchange > > exchange){} > > } > > ) > > </groovy> > > </transform> > > <transform> > > <constant>hoho</constant> > > </transform> > > </route> > > > > > > > > On Sat, May 31, 2014 at 2:52 AM, Claus Ibsen <[email protected]> > wrote: > > > >> Hi > >> > >> First about using IN vs OUT see this FAQ > >> http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html > >> > >> you should really just only use IN > >> > >> On Fri, May 30, 2014 at 9:49 PM, Max Bridgewater > >> <[email protected]> wrote: > >> > Now, this one is really puzzling me. What is the difference between > the > >> > following two routes? I thought they would produce the same thing. > >> > > >> > Right now, route1 produces "hoho" while the route2 produces "haha". > >> > > >> > > >> > <route id="route1"> > >> > <from uri="restlet:/route1"/> > >> > <onCompletion onCompleteOnly="true"> > >> > <transform> > >> > <groovy>exchange.getIn().setBody("haha"); > >> > exchange.getOut().setBody("haha"); "haha"</groovy> > >> > </transform> > >> > </onCompletion> > >> > <transform> > >> > <constant>hoho</constant> > >> > </transform> > >> > </route> > >> > > >> > <route id="route2"> > >> > <from uri="restlet:/route2"/> > >> > <transform> > >> > <groovy> > >> > exchange.getUnitOfWork().addSynchronization( > >> > new org.apache.camel.spi.Synchronization(){ > >> > public void > >> > onComplete(org.apache.camel.Exchange x){ > >> > x.getOut().setBody("haha"); > >> > } > >> > public void > >> onFailure(org.apache.camel.Exchange > >> > exchange){} > >> > } > >> > ) > >> > </groovy> > >> > </transform> > >> > <transform> > >> > <constant>hoho</constant> > >> > </transform> > >> > </route> > >> > > >> > > >> > > >> > > >> > > >> > Max. > >> > >> > >> > >> -- > >> Claus Ibsen > >> ----------------- > >> Red Hat, Inc. > >> Email: [email protected] > >> Twitter: davsclaus > >> Blog: http://davsclaus.com > >> Author of Camel in Action: http://www.manning.com/ibsen > >> hawtio: http://hawt.io/ > >> fabric8: http://fabric8.io/ > >> > > > > -- > Claus Ibsen > ----------------- > Red Hat, Inc. > Email: [email protected] > Twitter: davsclaus > Blog: http://davsclaus.com > Author of Camel in Action: http://www.manning.com/ibsen > hawtio: http://hawt.io/ > fabric8: http://fabric8.io/ >
