spring +active mq 重复接收消息问题
比如:第一次发送一条消息,内容为“1”,接收端会接收到一条消息,内容为“1”。第二次发送一条消息,内容为“2”,接收端会接收到2条消息,内容为“1,2”。这个是什么原因?找了好久没找问题的原因。可能是session的问题吗?
<!-- 配置connectionFactory -->
<bean id="connectionFactory"
class="org.apache.activemq.ActiveMQConnectionFactory">
<property name="brokerURL">
<value>tcp://192.168.61.125:61616</value>
</property>
</bean>
<bean id="jmsTemplate"
class="org.springframework.jms.core.JmsTemplate">
<property name="connectionFactory">
<ref bean="connectionFactory" />
</property>
<property name="pubSubDomain" value="false" />
<property name="sessionAcknowledgeMode" value="2" />
</bean>
<!-- 发送消息-->
<bean id="destination" class="org.apache.activemq.command.ActiveMQTopic">
<constructor-arg index="0" value="com.topic" />
</bean>
<!-- 接收server消息 -->
<bean id="webTopicDestination"
class="org.apache.activemq.command.ActiveMQTopic">
<constructor-arg index="0"
value="com.topic">
</constructor-arg>
</bean>
<!-- 接收消息监听的类 -->
<bean id="messageReceiver" class="com.mq.service.OnMessage">
</bean>
<!-- 消息监听 -->
<bean
class="org.springframework.jms.listener.DefaultMessageListenerContainer">
<property name="concurrentConsumers" value="1" />
<property name="connectionFactory" ref="connectionFactory" />
<property name="destination" ref="webTopicDestination" />
<property name="messageListener" ref="messageReceiver" />
<property name="pubSubNoLocal" value="false"></property>
<property name="sessionTransacted" value="true" />
</bean>
<networkConnectors>
<networkConnector uri="static://(tcp://localhost:61617)">
<excludedDestinations>
<queue physicalName="Consumer.*.VirtualTopic.>"/>
</excludedDestinations>
</networkConnector>
</networkConnectors>