前面一章中介绍了activemq的初步实现:基于ActiveMQ的Topic的数据同步——初步实现 下面来解决持久化订阅的问题: (1)使用queue,即队列时,每个消息只有一个消费者,所以,持久化很简单,只要保存到数据库即可
原理讲完,下面是配置实现: 修改jms-receiver.xml:原来的同样位置改成这样就可以了。在发送者中不用设置clinetIDPrefix属性也可以。 <!--异步调用消息 --> <bean id="receive" class="org.springframework.jms.listener.DefaultMessageListenerContainer"> <property name="connectionFactory" ref="jmsReceiverFactory"></property> <property name="destination" ref="destination"></property> <property name="messageListener" ref="messageListener"></property> <property name="subscriptionDurable" value="true"></property> <property name="clientId" value="www_01"></property> <property name="durableSubscriptionName" value="www"></property> </bean> 以下是mq中的截图: |
|
来自: WindySky > 《ActiveMQ》