Hi An update on my working on this issue.
I follow the principle outlined by James on the Pipeline restructure. The prepare exchange for next step is reduced to this principle: protected Exchange prepareExchange(Exchange exchange) { // now lets set the input of the next exchange to the output of the // previous message if it is not null if (exchange.hasOut()) { exchange.setIn(exchange.getOut()); exchange.setOut(null); } return exchange; } That fits well with the Pipes And Filters EIP: output is the next input. So the Pipelines is becoming nice and slick now. On Fri, Jul 10, 2009 at 7:05 AM, Claus Ibsen<claus.ib...@gmail.com> wrote: > Now that we have opened the box with IN OUT FAULT api changes I would > like to point out issues related to OUT > > Given this code: > > Exchange out = template.send("direct:start", new Processor() { > public void process(Exchange exchange) throws Exception { > exchange.getIn().setBody("Hello World"); > exchange.setPattern(ExchangePattern.InOnly); > } > }); > > And this route: > > from("direct:start").transform(constant("Bye World")); > > What would the expected output of Exchange be? > > The current code asserts this: > > assertEquals("Hello World", out.getIn().getBody()); > assertEquals("Bye World", out.getOut().getBody()); > > That looks fair. The route transforms (= set an OUT body) and we > preserve the original IN. > But the exchange pattern was InOnly but we get data in OUT also? Camel > does not adhere strictly to the patterns. > > > Now what if the route only changes the IN message (setBody only changes IN) > > from("direct:start").setBody(constant("Bye World")); > > What should the expected outcome be? > > Should it be as before? > > assertEquals("Hello World", out.getIn().getBody()); > assertEquals("Bye World", out.getOut().getBody()); > > Or as this: > > assertEquals("Bye World", out.getIn().getBody()); > assertEquals(null, out.getOut().getBody()); > > > Its actually now that easy to get a closure on this one. Either we should > - always store "result" in OUT and copy back the original input to IN > - OR try to adhere the exchange pattern, and store "result" in either > IN or OUT depending on the pattern. > > This is often only a matter when you send an Exchange to Camel. If you > use the sendBody then Camel will extract > the correct result and thus its not a problem here. > > > > > -- > Claus Ibsen > Apache Camel Committer > > Open Source Integration: http://fusesource.com > Blog: http://davsclaus.blogspot.com/ > Twitter: http://twitter.com/davsclaus > -- Claus Ibsen Apache Camel Committer Open Source Integration: http://fusesource.com Blog: http://davsclaus.blogspot.com/ Twitter: http://twitter.com/davsclaus