JMS
Spring Message-Driven POJOs
Submitted by rowell on Fri, 01/11/2008 - 14:18This 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!
Exposing a Spring POJO as a Lingo Service
Submitted by rowell on Fri, 01/11/2008 - 13:59Service Configuration:
<!-- Bean that implements com.samples.interface.Service -->
<bean id="serviceImpl" class="com.samples.impl.Service" />
<!-- Lingo Service Configuration -->
<bean id="lingoService" class="org.logicblaze.lingo.jms.JmsServiceExporter">
<property name="connectionFactory" ref="connectionFactory"/>
<property name="destination" ref="lingoQueue"/>
<property name="service" ref="serviceImpl"/>
<property name="serviceInterface" value="com.samples.interface.Service"/>
</bean>
<bean id="serviceImpl" class="com.samples.impl.Service" />
<!-- Lingo Service Configuration -->
<bean id="lingoService" class="org.logicblaze.lingo.jms.JmsServiceExporter">
<property name="connectionFactory" ref="connectionFactory"/>
<property name="destination" ref="lingoQueue"/>
<property name="service" ref="serviceImpl"/>
<property name="serviceInterface" value="com.samples.interface.Service"/>
</bean>
Client Configuration:
<!-- Lingo Client Configuration -->
<bean id="lingoClient" class="org.logicblaze.lingo.jms.JmsProxyFactoryBean">
<property name="connectionFactory" ref="connectionFactory"/>
<property name="destination" ref="lingoQueue"/>
<property name="serviceInterface" value="com.samples.interface.Service"/>
<property name="metadataStrategy" ref="metadataStrategy"/>
</bean>
<!-- define the metadata strategy -->
<bean id="metadataStrategy" class="org.logicblaze.lingo.SimpleMetadataStrategy">
<!-- enable async one ways -->
<constructor-arg value="true"/>
</bean>
<bean id="lingoClient" class="org.logicblaze.lingo.jms.JmsProxyFactoryBean">
<property name="connectionFactory" ref="connectionFactory"/>
<property name="destination" ref="lingoQueue"/>
<property name="serviceInterface" value="com.samples.interface.Service"/>
<property name="metadataStrategy" ref="metadataStrategy"/>
</bean>
<!-- define the metadata strategy -->
<bean id="metadataStrategy" class="org.logicblaze.lingo.SimpleMetadataStrategy">
<!-- enable async one ways -->
<constructor-arg value="true"/>
</bean>
Spring Managed Connection Factory Configuration
Submitted by rowell on Fri, 01/11/2008 - 11:14<bean id="eciManagedConnectionFactory"
class="com.sonicsw.sonicmq.j2ee.jmsra.impl.sonic.SonicManagedConnectionFactory">
<property name="brokerURL" value="${Broker}"/>
<property name="username" value="${BrokerUser}"/>
<property name="password" value="${BrokerPassword}"/>
</bean>
<bean id="connectionFactory" class="org.springframework.jca.support.LocalConnectionFactoryBean">
<property name="managedConnectionFactory" ref="eciManagedConnectionFactory"/>
</bean>
class="com.sonicsw.sonicmq.j2ee.jmsra.impl.sonic.SonicManagedConnectionFactory">
<property name="brokerURL" value="${Broker}"/>
<property name="username" value="${BrokerUser}"/>
<property name="password" value="${BrokerPassword}"/>
</bean>
<bean id="connectionFactory" class="org.springframework.jca.support.LocalConnectionFactoryBean">
<property name="managedConnectionFactory" ref="eciManagedConnectionFactory"/>
</bean>