I've written a simple request-reply application using Spring Integration and JMS gateways, but I need some help understanding how to configure its channels and gateways to get it to scale.
The application consists of a client and a server. The client sends request messages to a DirectChannel using a MessageChannelTemplate.doSendAndReceive() call. A JMS outbound gateway forwards messages from this request channel out over JMS, where they are read by a JMS inbound gateway on another JVM. A service activator registered on the remote request channel passes the message payload to the server MessageEndPoint. The service activator returns an Object which must be delivered to the Client who originated the request.
The XML I have so far is...
This setup works, but I have a few questions I'm hoping someone can help me with.
<integration:channel id="requestChannel" />
<integration:service-activator input-channel="requestChannel" ref="server" />
<bean id="connectionFactory" class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL" value="tcp://localhost:61616" />
<bean id="requestQueue" class="org.apache.activemq.command.ActiveMQQueue">
<constructor-arg value="poc.activemq.requestQueue" />
<!-- on client only -->
<jms:outbound-gateway id="outboundGateway" jms-queue="requestQueue" request-channel="requestChannel" />
<!-- on server only -->
<jms:inbound-gateway id="inboundGateway" destination="requestQueue" request-channel="requestChannel"
1. I'm getting a "removing non-serializable header" warning regarding the REPLY_CHANNEL header in the Client request. Should I not use MessageChannelTemplate's doSendAndReceive() method, and instead use a MessageBuilder and call setReplyChannelName()?
2. A new TemporaryQueue is being created on the JMS broker for every outgoing message when using MessageChannelTemplate's doSendAndReceive() method. Looking at JmsOutboundGateway source code, the instantiation of a new QueueRequestor object for each handleRequestMessage() call makes me think this is unavoidable. Can it be avoided?
3. ActiveMQ have a different take on how temporary queues should be used for the Request-Reply pattern, namely to keep a temporary queue per client and use correlation IDs to match responses to requests. (http : // activemq.apache.org/how-should-i-implement-request-response-with-jms.html) Is this approach possible?
4. What is the correct channel type of the request channel on the Server side? I would like the same JmsInboundGateway thread which is pulling messages off the JMS queue to execute the server activator code.
5. Is there anything you would change in the pasted XML?
Thank you very much in advance,