2
votes

We would be deploying Spring integration code to a web application running on a multiple tomcat servers. We have a JMS Outbound gateway like below. The question is whether it is possible that the message sent by one of the servlet container JVM (say tomcat1) can be received by another servlet container JVM (say tomcat2)? In our case, in the spring integration flow, we are splitting the message into multiple messages and sending it to JMS Outbound Gateway and once the response are received, we would be using aggregating the message back on the same JVM.

So it would become a problem if the response is received by other JVM. Does anyone know about this?

<int-jms:outbound-gateway id="wldpJMSGateway"
connection-factory="cachedConnectionFactory"
extract-reply-payload="true"
request-channel="wldpJMSGatewayChannel"
request-destination-name="WLDP.REQUEST.QUEUE"
reply-channel="wldpJMSResponseChannel"
reply-destination-name="WLDP.RESPONSE.QUEUE"
receive-timeout="5000"
extract-request-payload="true"
/> 
1

1 Answers

1
votes

The replies will go back to the correct gateway; a message selector is used.

EDIT

It's not documented in any detail (although it's hinted at in the discussion about correlation-key in the gateway attributes section) but rest assured that the replies only go to the originating gateway. The actual mechanism depends on configuration.

For your configuration, the message selector is based on the outgoing JMSMessageID...

String messageSelector = "JMSCorrelationID = '" + messageId + "'";

... which is uniquely allocated by the JMS client library. This relies on the receiver copying the message id to the correlation id (which is a common pattern and is implemented by the SI inbound gateway as well as Spring JMS MessageListenerAdapter).

Setting the correlation-key to JMSCorrelationID will tell the gateway to use that instead, in which case, it is set to a generated value and...

messageSelector = "JMSCorrelationID = '" + correlationId + "'";

...this relies on the receiver echoing back the correlation id (which is again the usual pattern).

If there is a <reply-listener/> and a correlation-key the correlation id (and selector expression) includes a unique identifier for the gateway instance.

Finally, if no reply queue is defined, a temporary queue is used.

So, as you can see, we have thought of all possibilities to ensure the replies go to the right place.