PDA

View Full Version : RequestReplyTemplate doubt



diippi
Apr 23rd, 2008, 10:58 AM
I want to establish a synchronous communication <request-reply> with 2 queues , i.e I will be using a request on one queue and expecting a synchronous reply back at other queue.
Is requestReplyTemplate the right thing for above scenario ?
I tried setting it up but am not able to recieve the response correctly, it does not reaches my replyhandler.
I am listening for the response through the jms-source and handing it over to the channel defined by requestReplyTemplate , but it is being sent off to the request queue instead.

In the code I see something called as RendezvousChannel listening for responses...I did not really understand.

The config is as follows :


<jms-target id="paymentsTxHistoryWmqProvider"
jms-template="paymentsTxHistoryMQJmsRequestTemplate"
channel="paymentsTxHistoryChannel" />

<jms-source id="paymentsTxHistoryWmqConsumer"
connection-factory="paymentsTxHistoryConnectionFactoryWMQ"
destination-name="${wmq.response.destination.name}"
channel="paymentsTxHistoryChannel" acknowledge="auto" />

<channel id="paymentsTxHistoryChannel" />

<beans:bean id="reqReplyTemplate" class="org.springframework.integration.channel.RequestRep lyTemplate">
<beans:constructor-arg ref="paymentsTxHistoryChannel"/>
</beans:bean>

Mark Fisher
Apr 23rd, 2008, 11:11 AM
The RequestReplyTemplate sets an "anonymous" channel as the 'returnAddress' property on the request Message prior to sending to a channel. However, in your case, you are waiting for a reply on the "jms-source" channel. Is that correct?

If so, you can take a look at the ResponseCorrelator. It is itself a MessageHandler that receives the responses and allows you to call getResponse(correlationId).

I noticed that you are setting the same channel for your jms-source and jms-target. If that jms-source is expecting responses based on the "reply-to" Destination of the jms-target's Messages, then you want to make sure to provide a separate channel for those responses (otherwise, it's going to try to send those responses right back to the responder).

We will be providing a proxy-based approach that hides these rather low-level components.

diippi
Apr 23rd, 2008, 11:44 AM
I understand that my response messages are being redirected to request queues because of setting the same channel in jms-source and jms-target .. I need to know whats the right way to recieve the response.
I do not have to define the jms-source if it can be done any other way..
I need to get handle on the response which is being sent on another queue , not necessarily defiend by 'replyTo' attribute.
Also, the messages do not have correlation id so to speak of, the actual correlation data is hidden inside the payload ..

Do I still need to look at responseCorrelator ? if so, do I have to configure it or its being done automatically and I just need to call the getResponse(Object correlationId) ?