Spring Message-Driven POJOs
Submitted by rowell on Fri, 01/11/2008 - 14:18
This is probably one of my favorite features of Spring. This simple configuration will enable any method of any class to receive JMS messages asynchonously and send a response, if needed...
<bean id="echoBean" class="com.samples.Echo" />
<jms:listener-container
connection-factory="connectionFactory"
destination-type="queue"
concurrency="10">
<jms:listener destination="com.samples.queue" ref="echoBean" method="echo"/>
</jms:listener-container>
<jms:listener-container
connection-factory="connectionFactory"
destination-type="queue"
concurrency="10">
<jms:listener destination="com.samples.queue" ref="echoBean" method="echo"/>
</jms:listener-container>
If echo has a return type, it will automatically be converted to a JMS Message and sent to the destination specified in the JMSReplyTo attribute of the incoming message. Sweet!