ActiveMQ 出现FixedBackOff 异常一直出现无限制的连接导致资源占用异常
来源:互联网 发布:淘宝怎么注册用户名 编辑:程序博客网 时间:2024/06/07 10:27
2017-10-16 09:45:33,809 ERROR [org.springframework.jms.listener.DefaultMessageListenerContainer] - Could not refresh JMS Connection for destination 'topic://SOMC_OKH_TOPIC' - retrying using FixedBackOff{interval=5000, currentAttempts=3, maxAttempts=unlimited}. Cause: Could not connect to broker URL: tcp://192.168.170.84:61616. Reason: java.net.ConnectException: Connection refused: connect
在做消息队列时出现连接服务器一直拒绝的情况,程序在后台出现了无限制的请求连接,导致资源不停的在访问,占用资源出现异常情况,从异常情况看 - retrying using FixedBackOff{interval=5000, currentAttempts=3, maxAttempts=unlimited}. 看出maxAttempts这个参数出现无限制的情况。根据FixedBackOff类去查看
package org.springframework.util.backoff;/** * A simple {@link BackOff} implementation that provides a fixed interval * between two attempts and a maximum number of retries. * * @author Stephane Nicoll * @since 4.1 */public class FixedBackOff implements BackOff {/** * The default recovery interval: 5000 ms = 5 seconds. */public static final long DEFAULT_INTERVAL = 5000;/** * Constant value indicating an unlimited number of attempts. */public static final long UNLIMITED_ATTEMPTS = Long.MAX_VALUE;private long interval = DEFAULT_INTERVAL;private long maxAttempts = UNLIMITED_ATTEMPTS;/** * Create an instance with an interval of {@value #DEFAULT_INTERVAL} * ms and an unlimited number of attempts. */public FixedBackOff() {}/** * Create an instance. * @param interval the interval between two attempts * @param maxAttempts the maximum number of attempts */public FixedBackOff(long interval, long maxAttempts) {this.interval = interval;this.maxAttempts = maxAttempts;}/** * Set the interval between two attempts in milliseconds. */public void setInterval(long interval) {this.interval = interval;}/** * Return the interval between two attempts in milliseconds. */public long getInterval() {return interval;}/** * Set the maximum number of attempts in milliseconds. */public void setMaxAttempts(long maxAttempts) {this.maxAttempts = maxAttempts;}/** * Return the maximum number of attempts in milliseconds. */public long getMaxAttempts() {return maxAttempts;}@Overridepublic BackOffExecution start() {return new FixedBackOffExecution();}private class FixedBackOffExecution implements BackOffExecution {private long currentAttempts = 0;@Overridepublic long nextBackOff() {this.currentAttempts++;if (this.currentAttempts <= getMaxAttempts()) {return getInterval();}else {return STOP;}}@Overridepublic String toString() {final StringBuilder sb = new StringBuilder("FixedBackOff{");sb.append("interval=").append(FixedBackOff.this.interval);String attemptValue = (FixedBackOff.this.maxAttempts == Long.MAX_VALUE ?"unlimited" : String.valueOf(FixedBackOff.this.maxAttempts));sb.append(", currentAttempts=").append(this.currentAttempts);sb.append(", maxAttempts=").append(attemptValue);sb.append('}');return sb.toString();}}}
需要设置maxAttempts的值,在spring 集成中配置
<bean id="backOff" class="org.springframework.util.backoff.FixedBackOff"> <property name="maxAttempts" value="3"/> </bean>
在监听器中配置该属性backOff 即可
<bean id="queueListenerContainer" class="org.springframework.jms.listener.DefaultMessageListenerContainer"> <property name="connectionFactory" ref="connectionFactory" /> <property name="destination" ref="demoTopicDestination" /> <property name="messageListener" ref="topicMessageListen" /> <property name="backOff" ref="backOff"/> <property name="sessionAcknowledgeMode" value="4"/> </bean>
结果出现连接不上的只有尝试连接3次
2017-10-16 09:45:33,809 ERROR [org.springframework.jms.listener.DefaultMessageListenerContainer] - Could not refresh JMS Connection for destination 'topic://SOMC_OKH_TOPIC' - retrying using FixedBackOff{interval=5000, currentAttempts=3, maxAttempts=3}. Cause: Could not connect to broker URL: tcp://192.168.170.84:61616. Reason: java.net.ConnectException: Connection refused: connect
阅读全文
1 0
- ActiveMQ 出现FixedBackOff 异常一直出现无限制的连接导致资源占用异常
- SQLServer出现连接异常
- JDBC连接SQLServer出现的异常
- odbc连接sqlserver2005出现的异常
- Jedis连接出现异常解决
- 对于异常出现,而导致android崩溃的处理
- DBCP连接池出现连接异常解决方案;
- 导致在Debug下没有异常在 Release 下却出现异常的代码
- mysql出现1067异常或1366错误的解决方案(字符集冲突导致插入数据异常)
- 连接mysql时出现的各种异常问题
- MYSQL连接一段时间不操作后出现异常的解决方案
- HIbernate 5 测试连接出现的 Unknown entity异常
- junit一直出现空指针异常 尼玛啊
- Solaris 环境下ActiveMQ关闭时出现异常
- jsp+sql server 2000连接出现异常
- JDBC连接oracle数据库出现ClassNotFoundException异常
- 连接oracle,出现了IO异常
- 求助?eclipse连接hbase出现如下异常
- python的一些疑问
- 如何对大数据软件产品进行测试?
- 八大排序算法-希尔排序
- Oracle数据库日期的处理
- wubi安装ubuntu DVD版
- ActiveMQ 出现FixedBackOff 异常一直出现无限制的连接导致资源占用异常
- Django 事务(参考文档与博客)
- curl 多线程请求 (可使用代理IP)
- pycharm激活(JetBrains IDEA 系列产品通用xx方法(license server))
- caffe 安装步骤与方法小结
- 10月16日 c语言 输入国际象棋棋盘
- java线程全面总结(基础易懂 适合新手)
- mac重启需重启本地svn服务
- linux系统Mysql5.6下载与安装