gpt4 book ai didi

jms - Spring JMS 和 ActiveMQ 在哪里查看死信队列中的消息

转载 作者:行者123 更新时间:2023-12-02 20:31:46 25 4
gpt4 key购买 nike

这是我的配置:

@Bean
ActiveMQConnectionFactory activeMQConnectionFactory() {
String url = this.environment.getProperty("jms.broker.url");
ActiveMQConnectionFactory connectionFactory = new ActiveMQConnectionFactory();
connectionFactory.setBrokerURL(url);
connectionFactory.setRedeliveryPolicy(redeliveryPolicy());
return connectionFactory;
}

@Bean
public RedeliveryPolicy redeliveryPolicy() {
RedeliveryPolicy redeliveryPolicy = new RedeliveryPolicy();
redeliveryPolicy.setInitialRedeliveryDelay(500);
redeliveryPolicy.setBackOffMultiplier(2);
redeliveryPolicy.setUseExponentialBackOff(true);
redeliveryPolicy.setMaximumRedeliveries(5);
return redeliveryPolicy;
}
.....

这是我的消费者:

@Service("msgConsumer")
public class MessageConsumer {

private static final String ORDER_RESPONSE_QUEUE = "thequeue.Q";

@JmsListener(destination = ORDER_RESPONSE_QUEUE, containerFactory = "jmsListenerContainerFactory")
public void receiveMessage(final Message<String> message) throws Exception {

MessageHeaders headers = message.getHeaders();
LOG.info("Application : headers received : {}", headers);

String response = message.getPayload();
LOG.info("Application : response received : {}",response);

if(response.equals("launch"))
throw new Exception("Error");
}
}

所以我在队列中放入了一条有效负载=“launch”的消息。

我想测试事务,如果有效负载等于“启动”,则会抛出异常。

因此,由于 redeliverypolicy,消费者尝试消费该消息 5 次。在 ActiveMq 队列列表中的第五个之后,我没有看到我发送的消息。

消息放置在哪里?在死信队列中?在哪里可以看到带有“启动”消息的死信队列?

谢谢。

最佳答案

ActiveMQ.DLQ - 请参阅the documentation here .

Once a message's redelivery attempts exceeds the maximumRedeliveries configured for the Redelivery Policy, a "Poison ACK" is sent back to the broker letting him know that the message was considered a poison pill. The Broker then takes the message and sends it to a Dead Letter Queue so that it can be analyzed later on.

The default Dead Letter Queue in ActiveMQ is called ActiveMQ.DLQ; all un-deliverable messages will get sent to this queue and this can be difficult to manage. So, you can set an individualDeadLetterStrategy in the destination policy map of the activemq.xml configuration file, which allows you to specify a specific dead letter queue prefix for a given queue or topic. You can apply this strategy using wild card if you like so that all queues get their own dead-letter queue, as is shown in the example below.

在控制台可以看到DLQ;您可以像任何其他队列一样使用它。

关于jms - Spring JMS 和 ActiveMQ 在哪里查看死信队列中的消息,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/48447895/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com