【问题标题】:How to retrieve message after last retry in a JMS, ActiveMQ and SimpleMessageListenerContainer setup?在 JMS、ActiveMQ 和 SimpleMessageListenerContainer 设置中最后一次重试后如何检索消息?
【发布时间】:2016-02-10 10:06:30
【问题描述】:

我有一个 Spring JMS,ActiveMQ 设置,我在其中使用与 POJO 消息侦听器关联的 SimpleMessageListenerContainer。我已经定义了一个 RedeliveryPolicy,如果 POJO 消息侦听器中有异常,则在 4 次尝试后将消息发送到 DLQ。我想在重试用尽后访问该消息,可以使用 SMLC 吗? DefaultMessageListenerContainer 呢?

【问题讨论】:

    标签: java spring activemq spring-jms message-listener


    【解决方案1】:

    您需要另一个容器来监听 DLQ。

    或者您可以在 DLQ 上使用JmsTemplate.receive() 按需获取它们。

    【讨论】:

    • 有没有办法在不听 DLQ 的情况下获得对消息的引用(可能就在它被发送到 DLQ 之前)?要求是不要碰DLQ。
    • 仅供参考,想法是:尝试发送消息 4 次,如果失败,则在最后一次尝试后获取消息并将其标记为数据库中的“错误”。让 DLQ 受到异常情况的监控。
    • JMS 2.0 made JMSXDeliveryCount mandatory。一些 1.1 经纪人支持它。因此,您可以使用计数来确定已进行了多少次尝试。 "JMSXDeliveryCount is not a new property; it was defined in JMS 1.1. However, in JMS 1.1, it was optional for a JMS provider to actually set it, which meant application code that used it was not portable. In JMS 2.0, it becomes mandatory for JMS providers to set this property, allowing portable applications to make use of it."
    • JMSXDeliveryCount 在不监听 DLQ 的情况下帮助创建解决方案。
    猜你喜欢
    • 2011-06-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2017-06-29
    • 2019-01-09
    相关资源
    最近更新 更多