ActiveMQ InactivityIOException: Channel was inactive for too (>30000) long 处理方案

生产服务器上,MQ Produce和consumer端同时报如下错误,导致不能正常工作。

Transport (tcp://132.97.122.168:61616) failed, reason: org.apache.activemq.transport.InactivityIOException: Channel was inactive for too (>30000) long: tcp://132.97.122.168:61616, attempting to automatically reconnect


官网解释如下:

maxInactivityDuration=30000
The maximum inactivity duration (before which the socket is considered dead) in milliseconds. On some platforms it can take a long time for a socket to appear to die, so we allow the broker to kill connections if they are inactive for a period of time. Use by some transports to enable a keep alive heart beat feature. Set to a value <= 0 to disable inactivity monitoring.


即:配置JMS连接最大闲置时间(消息服务器无消息)
该wireFormat.maxInactivityDuration 的默认值是30000ms
wireFormat.maxInactivityDuration=0 这样的参数, wireFormat.maxInactivityDuration是心跳参数。
避免ActiveMQ在一段时间没有消息发送时抛出 "Channel was inactive for too long"异常。该异常会关闭连接,虽然client端会重连成功,但是不能发送数据,然后继续报下面异常:

2014-10-30 00:49:49 [ ActiveMQ Task-3:529216111 ] - [ INFO ] Successfully reconnected to tcp://132.97.122.168:61616
2014-10-30 00:49:49 [ ActiveMQ Transport: tcp:///132.97.122.168:61616@41298:529216129 ] - [ WARN ] Transport (tcp://132.97.122.168:61616) failed, reason: java.net.SocketException: Connection reset, attempting to automatically reconnect

解决方案:wireFormat.maxInactivityDuration=0,禁用InactivityMonitor
即改成如下格式:

failover:(tcp://172.26.7.15:61616?wireFormat.maxInactivityDuration=0,tcp://172.26.7.17:61616?wireFormat.maxInactivityDuration=0,tcp://172.26.7.18:61616?wireFormat.maxInactivityDuration=0)

测试如下
改之前:

 


禁用后:

 


————————————————
版权声明:本文为CSDN博主「weizs_999」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/u011270461/article/details/40827757

posted @ 2023-06-15 19:45  疯子110  阅读(1506)  评论(0编辑  收藏  举报