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/09/01 05:17:14 UTC
Re: Possibility of using inOut
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