AciveMq+spring 一个客户端 无论消费多少topic,使终一个 connection
//多个 topic topic2配置
<bean id="topic" value="test.mq.topic" />
</bean>
<!-- and this is the message listener container -->
<bean id="jmsContainer"
ref="jmsFactoryReceive" />
<property name="destination" ref="topic"></property>
<property name="messageListener" ref="messageListener" />
</bean>
<bean id="topic2" value="test.mq.topic2" />
</bean>
<bean id="jmsContainer2"
ref="jmsFactoryReceive" />
<property name="destination" ref="topic2"></property>
<property name="messageListener" ref="messageListener" />
</bean>
最初的连接工厂配置:
<bean id="jmsFactoryReceive" class="org.apache.activemq.pool.PooledConnectionFactory" destroy-method="stop">
<property name="connectionFactory">
<bean class="test.MyActiveFactory">
<property name="brokerURL">
<value>tcp://192.168.0.141:61616</value>
</property>
</bean>
</property>
</bean>
这样connection由池来管理 ,如maxThread设置为1,多个session可以共用这个池中的这个连接,达到一个客户端,无论接受多少个topic消息,即使终一个连接。