spring jms使用activemq 持久订阅topic
最近在学spring. 在学习到spring集成jms的时候碰到了topic持久订阅的问题。几经努力,终于找到了配置方法。在此分享下。如有更好的方法,望分享下。配置文件如下:
applicationContext-sender.xml
-----------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
"http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
<bean id="connectionFactory" value="tcp://localhost:61616"></property>
</bean>
</property>
</bean>
<bean id="dest" ref="connectionFactory"></property>
<property name="defaultDestination" ref="dest"></property>
<property name="pubSubDomain" value="true"></property></bean>
<bean id="messageSender" ref="jmsTemplate"></property>
</bean>
</beans>
-------------------------
applicationContext-receiver.xml
-------------------------
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN"
"http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<beans>
<bean id="connectionFactory" value="tcp://localhost:61616"></property>
</bean>
</property>
</bean>
<bean id="dest" value="mydest?consumer.retroactive=true&consumer.pref etchSize=10"></property></bean>
<bean id="jmsTemplate"
ref="connectionFactory"></property>
<property name="defaultDestination" ref="dest"></property>
</bean>
<bean id="messageReceiver" ref="jmsTemplate"></property>
</bean>
</beans>