Spring-based JMS Client实现
Spring 针对 ActiveMQ提供了许多帮助类,简化了JMS Client 编写。
1. Configuring JMS connections
??? (1) 配置ActiveMQConnectionFactory:
<bean id="jmsConnectionFactory" value="tcp://localhost:61616" /><property name="userName" value="admin" /><property name="password" value="password" /></bean>
??? (2) 配置池链接以提升性能:PooledConnectionFactory:???
<bean id="pooledJmsConnectionFactory" ref="jmsConnectionFactory" /></bean>
???? PooledConnectionFactory依赖JAR:commons-pool.
2. Configuring JMS destinations
<bean id="cscoDest" /></bean>
?3. Creating JMS consumers
<!-- The message listener --><bean id="portfolioListener" ref="jmsConnectionFactory" /><property name="destination" ref="cscoDest" /><property name="messageListener" ref="portfolioListener" /></bean>
?4. Creating JMS producers
???? JMS publisher configuration in Spring:
<!-- Spring JMS Template --><bean id="jmsTemplate" ref="pooledJmsConnectionFactory" /></bean><bean id="stockPublisher" ref="jmsTemplate" /><property name="destinations"><list><ref local="cscoDest" /><ref local="orclDest" /></list></property></bean>