【发布时间】:2017-12-13 14:19:06
【问题描述】:
如何配置 ActiveMQ Artemis 或我的 Spring JMS 客户端在出错时不使用任何其他消息?
我的代理配置如下:
<addresses>
<address name="SimplePointToPoint">
<anycast>
<queue name="SimplePointToPoint"/>
</anycast>
</address>
</addresses>
<address-settings>
<address-setting match="SimplePointToPoint">
<max-delivery-attempts>-1</max-delivery-attempts>
</address-setting>
</address-settings>
这是我的消费者的代码:
@JmsListener(destination = "SimplePointToPoint")
public void consumeMessage(Message<String> message) {
if (message.getPayload().contains("error"))
throw new RuntimeException();
log.info("received message: {}", message.getPayload());
}
发送message1、message2 with error 和message3 时,我希望消费者处理message1 并永远重试message2 with error。在成功使用 message2 with error 之前,不应处理 message3。实际发生的是message3 在重试之间被消耗。如何改变这种行为?有什么想法吗?
【问题讨论】:
标签: spring spring-jms activemq-artemis