I just checked the code of Camel there is a big difference between the
inOut("jms:xmlOrders") and to("jms:xmlOrders?exchangePattern=InOut")
inOut("jms:xmlOrders") will set the exchange pattern of the exchange to
be InOut, and send the exchange to the endpoint.
to("jms:xmlOrders?exchangePattern=InOut") will just send the exchange to
the endpoint, it will not change the exchange pattern of the exchange.
The exchangePattern only takes effect on the jms endpoint consumer when
it creates the Exchange.
The issue of your first route is bean(ValidatorBean.class, "validate")
will set the exchange pattern to InOut, and jms:valid endpoint will
expect the response from the "stream:out" endpoint which will block the
message which need to send back to "jms:xmlOrders".
Remove the bean() part can remove the block, so you can get what you need.
On 11/4/10 8:33 PM, Bruno Dusausoy wrote:
On Thu, 04 Nov 2010 11:23:46 +0100, Bruno Dusausoy<[email protected]>
wrote:
Hi,
[...]
So my question is : "is there a difference between setting the
exchangePattern option and using the inOut() method ?"
[...]
Ok, I think I've tightened the scope of the problem.
This code doesn't work (as explained before) :
from("file:src/data?noop=true").to("jms:incomingOrders");
from("jms:incomingOrders")
.inOut("jms:xmlOrders");
// ValidatorBean.validate() always return the boolean value "true".
from("jms:xmlOrders")
.bean(ValidatorBean.class, "validate")
.to("jms:valid");
from("jms:valid").to("stream:out");
If I use exactly the same, only replacing
from("jms:incomingOrders")
.inOut("jms:xmlOrders");
with
from("jms:incomingOrders")
.to("jms:xmlOrders?exchangePattern=InOut");
It works as expected, resulting in displaying "true" to the console.
*But*
When removing the last route and the .to("jms:valid"), like this :
from("file:src/data?noop=true").to("jms:incomingOrders");
from("jms:incomingOrders")
.inOut("jms:xmlOrders");
from("jms:xmlOrders")
.bean(ValidatorBean.class, "validate");
it always work, either by using inOut() or the to() with
"exchangePattern=InOut" option.
Can someone tell me why is it this way ?
Regards.
--
Willem
----------------------------------
FuseSource
Web: http://www.fusesource.com
Blog: http://willemjiang.blogspot.com (English)
http://jnn.javaeye.com (Chinese)
Twitter: willemjiang