You are viewing a plain text version of this content. The canonical link for it is here.
Posted to users@camel.apache.org by Muhammad Ichsan <ic...@gmail.com> on 2010/08/31 12:59:34 UTC
Possibility of using inOut
Dear All
I want to know if this is possible
<route>
<from uri="direct:begining" />
<inOut uri="activemq:input?replyTo=output" />
<to uri="file:///tmp/result.txt" />
</route>
<route>
<from uri="activemq:input" />
<to uri="bean:communicator?method=justSendNoWait" />
</route>
<route>
<from uri="bean:communicator?method=readResponse" />
<to uri="activemq:output" />
</route>
How to implement communicator then?
Thanks
--
~The best men are men who benefit to others
http://michsan.web.id 一緒に勉強しましょう!
Yang berkualitas memang beda rasanya!
http://rizqi-cookies.com
Re: Possibility of using inOut
Posted by Willem Jiang <wi...@gmail.com>.
Muhammad Ichsan wrote:
> Dear All
>
> I want to know if this is possible
>
> <route>
> <from uri="direct:begining" />
> <inOut uri="activemq:input?replyTo=output" />
> <to uri="file:///tmp/result.txt" />
> </route>
>
> <route>
> <from uri="activemq:input" />
> <to uri="bean:communicator?method=justSendNoWait" />
> </route>
>
> <route>
> <from uri="bean:communicator?method=readResponse" />
> <to uri="activemq:output" />
> </route>
>
> How to implement communicator then?
>
> Thanks
>
As the <from uri="bean;communicator?method=readResponse"> can't work for
you, I think you can define the routes like this, the bean:communication
need to make sure it sets a right correlationId message header.
<route>
<from uri="direct:begining" />
<to uri="activemq:input?replyTo=output" />
<to uri="file:///tmp/result.txt" />
</route>
<route>
<from uri="activemq:input" />
<to uri="bean:communicator?method=sendRequestAndGetResponse" />
<to uri="activemq:output" />
</route>
Willem
Re: Possibility of using inOut
Posted by Muhammad Ichsan <ic...@gmail.com>.
2010/8/31 Claus Ibsen <cl...@gmail.com>
> Read chapter 7 in the Camel book how to do request/reply over JMS.
>
> The 2nd route (amq:input) will "detect" the JMSReplyTo header
> automatic and automatic return back the reply. So you don't have to do
> that manually.
> Just at the end of the routing the message is send back to the
> JMSReplyTo destination.
>
Sorry, I think you don't get it. The communicator is a socket bean which
maintain connection to remote host. A message sent to it can be a request
(which we can wait a response) and can be also a response.
When a response is coming in from bean:communicator?method=readResponse,
then I have to make the correlation id is the same with corresponding
request and it is sent back to amq:output. Else (when a request coming
from bean:communicator?method=readResponse), I just throw it to another
queue and do not care about correlation id.
The problem is I don't know exactly how to implement this communicator. This
is my snippet:
void justSendNoWait(Exchange x) {
MyMessage m = x.getIn().getBody(MyMessage.class);
if (m.isRequest()) {
saveCorrelationId(m.getTraceNumber(),
x.getIn().getHeader("JMSCorrelationID"));
x.setPattern(ExchangePattern.InOnly); // I don't know if this is
necessary to make the message not delivered to it's caller, but instead wait
for future response
}
}
void readResponse(Exchange x) {
MyMessage m = x.getIn().getBody(MyMessage.class);
if (m.isResponse()) {
String cid = readCorrelationId(m.getTraceNumber());
x.getOut().setHeader("JMSCorrelationID", cid);
x.getOut().setBody(x.getIn().getBody());
}
}
Is this correct? I have problem with this.
Thanks
--
~The best men are men who benefit to others
http://michsan.web.id 一緒に勉強しましょう!
Yang berkualitas memang beda rasanya!
http://rizqi-cookies.com
Re: Possibility of using inOut
Posted by Claus Ibsen <cl...@gmail.com>.
Read chapter 7 in the Camel book how to do request/reply over JMS.
The 2nd route (amq:input) will "detect" the JMSReplyTo header
automatic and automatic return back the reply. So you don't have to do
that manually.
Just at the end of the routing the message is send back to the
JMSReplyTo destination.
On Tue, Aug 31, 2010 at 12:59 PM, Muhammad Ichsan <ic...@gmail.com> wrote:
> Dear All
>
> I want to know if this is possible
>
> <route>
> <from uri="direct:begining" />
> <inOut uri="activemq:input?replyTo=output" />
> <to uri="file:///tmp/result.txt" />
> </route>
>
> <route>
> <from uri="activemq:input" />
> <to uri="bean:communicator?method=justSendNoWait" />
> </route>
>
> <route>
> <from uri="bean:communicator?method=readResponse" />
> <to uri="activemq:output" />
> </route>
>
> How to implement communicator then?
>
> Thanks
>
> --
> ~The best men are men who benefit to others
> http://michsan.web.id 一緒に勉強しましょう!
>
> Yang berkualitas memang beda rasanya!
> http://rizqi-cookies.com
>
--
Claus Ibsen
Apache Camel Committer
Author of Camel in Action: http://www.manning.com/ibsen/
Open Source Integration: http://fusesource.com
Blog: http://davsclaus.blogspot.com/
Twitter: http://twitter.com/davsclaus