You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Bruno Dusausoy <bd...@yp5.be> on 2010/11/04 11:23:46 UTC
Request reply
Hi,
I'm tinkering with request-reply messaging over JMS, with help from
"Camel in Action" book (chapter 7, jms).
If I use
from("jms:incomingOrders")
.to("jms:xmlOrders?exchangePattern=InOut");
as endpoint, it works well, I get my response back.
But if I try with inOut() like this :
from("jms:incomingOrders")
.inOut("jms:xmlOrders");
I get nothing at first, but when the camel context tries to shut
itself down, I get :
[...]
4 nov. 2010 11:20:51
org.apache.camel.impl.DefaultShutdownStrategy$ShutdownTask run
INFO: Waiting as there are still 2 inflight and pending exchanges to
complete before we can shutdown
[...]
So my question is : "is there a difference between setting the
exchangePattern option and using the inOut() method ?"
Regards.
--
Bruno Dusausoy
YP5 Software
--
Pensez environnement : limitez l'impression de ce mail.
Please don't print this e-mail unless you really need to.
Re: Request reply
Posted by Bruno Dusausoy <bd...@yp5.be>.
On Fri, 05 Nov 2010 14:54:22 +0800, Willem Jiang
<wi...@gmail.com> wrote:
> 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.
>
Thanks a lot for the explanation !
--
Bruno Dusausoy
YP5 Software
--
Pensez environnement : limitez l'impression de ce mail.
Please don't print this e-mail unless you really need to.
Re: Request reply
Posted by Willem Jiang <wi...@gmail.com>.
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<bd...@yp5.be>
> 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
Re: Request reply
Posted by Bruno Dusausoy <bd...@yp5.be>.
On Thu, 04 Nov 2010 11:23:46 +0100, Bruno Dusausoy <bd...@yp5.be>
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.
--
Bruno Dusausoy
YP5 Software
--
Pensez environnement : limitez l'impression de ce mail.
Please don't print this e-mail unless you really need to.