PDA

View Full Version : Problem nesting RequestReplyTemplate



fsancho
Aug 13th, 2008, 07:11 AM
Hi

I having problems with a ReplyRequest concatenation. I have two templates nested. The second reply is the reply of the first one.



<beans:bean id="CommunicationManager" class="org.sescam.cisos.bie.integration.communication.Com municationManager">
<beans:property name="outputChannel" ref="inputMsgChan" />
</beans:bean>
<service-activator ref="CommunicationManager" method="sendMessage" input-channel="endpointInput" />

<beans:bean id="TransactionManager" class="org.sescam.cisos.bie.integration.transaction.Trans actionManager">
<beans:property name="outputChannel" ref="normalizedMsgChan" />
</beans:bean>


The first RequestReplyTemplate send a message to CommunicationManager bean through endpointInput channel


RequestReplyTemplate template = new RequestReplyTemplate(endpointInput);
Message<?> reply = template.request(new GenericMessage<String>(message+" : "+this.getId()));


CommunicationManager process the message and make a new RequestReplyTemplate.


public Message<?> sendMessage(Message<?> message){
MessageHeader header = message.getHeader();

RequestReplyTemplate template = new RequestReplyTemplate(this.outputChannel);
Message<?> reply = template.request(message);
return new GenericMessage<String>((String)reply.getPayload()+": exito");

}


The second RequestReplyTemplate works ok, but the reply doesn't arrive to the first template, i get the following error



13-ago-2008 11:38:08 org.springframework.integration.scheduling.Message PublishingErrorHandler handle
WARNING: failure occurred in messaging task with message: [ID=89e99635-d10c-40ec-a407-845f28880797][Header=[CorrelationID=993b2cd2-9537-4d42-a0c7-397b53a70e79][Properties={}][Attributes={TMTime=1218623887218, CMTime=1218623887218}][Timestamp=Wed Aug 13 11:38:07 GMT+01:00 2008][Expiration=null][Priority=NORMAL][Sequence #1 (of 1)]][Payload='TM: mensaje1 : 13: exito']
org.springframework.integration.message.MessageDel iveryException: unable to send reply message within alloted timeout of 1000 milliseconds


Where is the problem?

Mark Fisher
Aug 13th, 2008, 07:37 AM
I think your problem is related to the service-activator for CommunicationManager. The "sendMessage" method returns a Message, but there is no 'output-channel' on service-activator.

It would probably be much simpler if you rely on the service-activator for the request/reply handling, since there would be no need to use the RequestReplyTemplate in your code. For example:


<beans:bean id="CommunicationManager" class="org.sescam.cisos.bie.integration.communication.Com municationManager"/>

<service-activator ref="CommunicationManager" method="sendMessage" input-channel="endpointInput" output-channel="inputMsgChan" />