You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by iamniche <nh...@scottlogic.co.uk> on 2012/07/05 11:06:50 UTC

Important difference in behaviour between processRef and beanRef

Hello,

I have found an important difference in behaviour between processRef and
beanRef, which maybe someone can explain to me, please.

For example, take the following route, which consumes from a queue, enriches
the message and then finally sends the message to another queue (where
EnricherProcessor is a Processor, implementing the 'process' method)

 from(REQUEST_QUEUE_ENDPOINT)
        	.processRef(EnricherProcessor.ENRICHERPROCESSOR_ID)
        	.to(RESPONSE_QUEUE_ENDPOINT);

When using a Processor, the original message, not the enriched one, reaches
the response queue, which is not what is expected.

Compare this to the beanRef version:

from(REQUEST_QUEUE_ENDPOINT)
        	.beanRef(EnricherProcessor.ENRICHERPROCESSOR_ID, "process")
        	.to(RESPONSE_QUEUE_ENDPOINT);

Using beanRef, the enriched messaged reaches the response queue.

Why the difference in this behaviour, please?

In the Processor we only ever manipulate using exchange.getIn() since then
the 'In' is copied to the 'Out' if getOut() has not been called (as per the
documentation)

Could someone explain this difference please?

Cheerio,
Nic

--
View this message in context: http://camel.465427.n5.nabble.com/Important-difference-in-behaviour-between-processRef-and-beanRef-tp5715525.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Important difference in behaviour between processRef and beanRef

Posted by SimonH <sm...@scottlogic.co.uk>.
iamniche, I have found a similar problem - my modifications are discarded
when using a Jms-to-ProcessRef-to-Jms route.  I looked into it and found
that under some conditions, the Jms outbound endpoint sends on the original,
unmodified Jms message.  I don't think it is specifically related to
'processRef'; the behaviour potentially affects all Jms-to-Jms routes; it's
just that other use cases - including 'beanRef' - seem to /accidentally /
avoid this behaviour.

I don't have the full story on this yet, though.  I have raised a new topic:

http://camel.465427.n5.nabble.com/Jms-component-discarding-transformations-td5715738.html

--
View this message in context: http://camel.465427.n5.nabble.com/Important-difference-in-behaviour-between-processRef-and-beanRef-tp5715525p5715741.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Important difference in behaviour between processRef and beanRef

Posted by Claus Ibsen <cl...@gmail.com>.
The REQUEST_QUEUE_ENDPOINT has a say what MEP is being used.


On Thu, Jul 5, 2012 at 12:13 PM, iamniche <nh...@scottlogic.co.uk> wrote:
> So I have had a look at the exchange pattern and appears that the following
> route defaults to InOnly:
>
> from(REQUEST_QUEUE_ENDPOINT)
>                 .processRef(EnricherProcessor.ENRICHERPROCESSOR_ID)
>                 .to(RESPONSE_QUEUE_ENDPOINT);
>
> So if I do the following:
>
> from(REQUEST_QUEUE_ENDPOINT)
>                 .setExchangePattern(ExchangePattern.InOut)
>                 .processRef(EnricherProcessor.ENRICHERPROCESSOR_ID)
>                 .to(RESPONSE_QUEUE_ENDPOINT);
>
> Then it all works as expected.
>
> It is certainly not intuitive that a route with from(q1) and to(q2) be
> InOnly...
>
> I thought that InOut should used when you want to send a request and consume
> the response?
> As per http://camel.apache.org/request-reply.html
>
> Cheerio,
> Nic
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Important-difference-in-behaviour-between-processRef-and-beanRef-tp5715525p5715532.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen

Re: Important difference in behaviour between processRef and beanRef

Posted by iamniche <nh...@scottlogic.co.uk>.
So I have had a look at the exchange pattern and appears that the following
route defaults to InOnly:

from(REQUEST_QUEUE_ENDPOINT)
        	.processRef(EnricherProcessor.ENRICHERPROCESSOR_ID)
        	.to(RESPONSE_QUEUE_ENDPOINT);

So if I do the following:

from(REQUEST_QUEUE_ENDPOINT)
        	.setExchangePattern(ExchangePattern.InOut)
        	.processRef(EnricherProcessor.ENRICHERPROCESSOR_ID)
        	.to(RESPONSE_QUEUE_ENDPOINT);

Then it all works as expected.

It is certainly not intuitive that a route with from(q1) and to(q2) be
InOnly...

I thought that InOut should used when you want to send a request and consume
the response?
As per http://camel.apache.org/request-reply.html

Cheerio,
Nic

--
View this message in context: http://camel.465427.n5.nabble.com/Important-difference-in-behaviour-between-processRef-and-beanRef-tp5715525p5715532.html
Sent from the Camel - Users mailing list archive at Nabble.com.

Re: Important difference in behaviour between processRef and beanRef

Posted by Claus Ibsen <cl...@gmail.com>.
Hi

See this FAQ
http://camel.apache.org/using-getin-or-getout-methods-on-exchange.html


On Thu, Jul 5, 2012 at 11:06 AM, iamniche <nh...@scottlogic.co.uk> wrote:
> Hello,
>
> I have found an important difference in behaviour between processRef and
> beanRef, which maybe someone can explain to me, please.
>
> For example, take the following route, which consumes from a queue, enriches
> the message and then finally sends the message to another queue (where
> EnricherProcessor is a Processor, implementing the 'process' method)
>
>  from(REQUEST_QUEUE_ENDPOINT)
>                 .processRef(EnricherProcessor.ENRICHERPROCESSOR_ID)
>                 .to(RESPONSE_QUEUE_ENDPOINT);
>
> When using a Processor, the original message, not the enriched one, reaches
> the response queue, which is not what is expected.
>
> Compare this to the beanRef version:
>
> from(REQUEST_QUEUE_ENDPOINT)
>                 .beanRef(EnricherProcessor.ENRICHERPROCESSOR_ID, "process")
>                 .to(RESPONSE_QUEUE_ENDPOINT);
>
> Using beanRef, the enriched messaged reaches the response queue.
>
> Why the difference in this behaviour, please?
>
> In the Processor we only ever manipulate using exchange.getIn() since then
> the 'In' is copied to the 'Out' if getOut() has not been called (as per the
> documentation)
>
> Could someone explain this difference please?
>
> Cheerio,
> Nic
>
> --
> View this message in context: http://camel.465427.n5.nabble.com/Important-difference-in-behaviour-between-processRef-and-beanRef-tp5715525.html
> Sent from the Camel - Users mailing list archive at Nabble.com.



-- 
Claus Ibsen
-----------------
FuseSource
Email: cibsen@fusesource.com
Web: http://fusesource.com
Twitter: davsclaus, fusenews
Blog: http://davsclaus.com
Author of Camel in Action: http://www.manning.com/ibsen