如何限制JMS DefaultMessageListenerContainer重试消息的次数? [英] How do I limit the amount of times a JMS DefaultMessageListenerContainer will retry a message?

查看:543
本文介绍了如何限制JMS DefaultMessageListenerContainer重试消息的次数?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用Spring JMS连接到Websphere MQ服务器.我实现了SessionAwareListener接口来创建自定义侦听器,将旧代码重用于业务逻辑.

I am using Spring JMS to connect to a Websphere MQ server. I implemented the SessionAwareListener interface to create a custom listener, reusing old code for the business logic.

在测试时,侦听器抛出StringIndexOutOfBoundsException,但我未能捕获.但是,我在日志中看到以下内容打印了约32次,然后DMLC停止了.

While testing, the listener throws a StringIndexOutOfBoundsException, which I fail to catch. However, I see in the log the following printed about 32 times, then the DMLC stops.

WARN  - Execution of JMS message listener failed

是否有一种方法可以控制DMLC重试消息的频率以及如何处理未捕获的异常?

Is there a way to control how often the DMLC will retry a message, and how to handle uncaught exceptions?

推荐答案

您始终可以检查JMSDeliveryCount.如果它大于您认为的最大值,那么就不要处理该消息并返回.

You can always check the JMSDeliveryCount. If it is more than the number you consider as maximum then just don't process the message and return.

您还可以配置您的Websphere 以进行移动尝试几次后,将错误消息发送到异常目标.

You can also configure your Websphere to move the bad message to the exception destination after some attempts.

这篇关于如何限制JMS DefaultMessageListenerContainer重试消息的次数?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆