我似乎无法弄清楚这一点... 这在 JAVA 中完美运行:
// Create a Session
Session session = connection.createSession(false, Session.CLIENT_ACKNOWLEDGE); // << means we have to acknowledge that we processed it!
但是当我创建 Spring Bean 时,我无法让 CLIENT_ACKNOWLEDGE 工作。看起来它会自动确认所有消息。
<bean id="testListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer" lazy-init="true">
<property name="connectionFactory" ref="amqConnectionFactory" />
<property name="destinationName" value="MyQueue" />
<property name="messageListener" ref="testListener" />
<property name="autoStartup" value="false"/>
<property name="sessionAcknowledgeModeName" value="CLIENT_ACKNOWLEDGE"/>
<property name="sessionTransacted" value="true"/>
<property name="concurrency" value="2"/>
</bean>
我缺少什么吗?
最佳答案
Spring 中的 DMLC 在您的配置中启用了事务,而在 Java 示例中,您禁用了事务。事务优先于任何确认模式。因此,选择是否应该选择交易或客户端确认,因为您不能同时选择两者。
关于java - ActiveMQ Spring CLIENT_ACKNOWLEDGE 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29782713/