camel-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "William Tam" <>
Subject Re: Strange behaviour of bean processor
Date Tue, 08 Jul 2008 20:57:42 GMT
Hi Sergey,

I think what's going on is, camel creates a route that includes a
pipeline processor to wrap the two "proc" processors if your route
looks like: from("activemq:a").process(proc).process(proc),

The debug message shows the route as follow:

2008-07-08 16:30:25,158 [main           ] DEBUG BeanInOutPatternTest
        - Routing Rules are:
[EventDrivenConsumerRoute[Endpoint[activemq:a] ->

At the end of the processor chain, the pipeline processor copies and
sets the out message in the Pipeline.process() method:
ExchangeHelper.copyResults(original, nextExchange).

That's how the out message is set even though it is not set by your processor.

If your route is: from("activemq:a").process(proc).process(proc),
there is no pipeline processor and the out body will remain null.  The
client won't get a reply.

2008-07-08 16:21:21,130 [main           ] DEBUG BeanInOutPatternTest
        - Routing Rules are:
[EventDrivenConsumerRoute[Endpoint[activemq:a] ->

(attached a test)


On Mon, Jul 7, 2008 at 8:18 AM, S.R. <> wrote:
> I'm trying to understand how the routes work, and especially, how the bean
> processors interact and make replies (for InOut pattern).
> I have a following code:
> // Processor
> Processor proc = new Processor() {
>            public void process(Exchange exchange) throws Exception {
>                // exchange.getOut().setBody(exchange.getIn().getBody() + "
> Reply "); - In this case all works fine!
>                exchange.getIn().setBody(exchange.getIn().getBody() + "
> Reply ");
>            }
>        };
> // Route
> from("jms:testQueue").process(proc).process(proc);
> Other component sends the JMS message "abcd" to the "jms:testQueue" with
> JMSReplyTo field set to "jms:replies", then listens the "jms:replies" for
> response, and retrieves response like "[Processor]abcd Reply Reply " as
> expected.
> But when I remove the last process(proc) element like:
> from("jms:testQueue").process(proc),
> and then repeat the scenario above, no replies sent on "jms:replies", and
> also, no exceptions thrown telling that no response during some timeout...
> Is that expected behavior and maybe I have wrong understanding? I think it
> should either reply in both cases or not reply in both cases (and throw
> exception about no response).
> Also, it's a bit confusing when exchange.setIn(...) and exchange.setOut(..)
> has the almost the same effect. As I've understood it, if we call
> exchange.setOut(Out) then that Out will become the Exchange.In for the next
> chain processor element, and if we don't, then we will have the same
> Exchange.In in the next processor. In any case, we will have the same result
> excluding the situation described above.
> Thank you,
> Sergey
> --
> View this message in context:
> Sent from the Camel - Users mailing list archive at

View raw message