如何配置 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
message3
message2 with error
message3