camel-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Claus Ibsen <>
Subject Re: [DISCUSS] Faults and Exceptions in Camel
Date Fri, 10 Jul 2009 05:05:39 GMT
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");

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:

View raw message