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)


测试如下

改之前:ActiveMQ InactivityIOException: Channel was inactive for too (>30000) long 处理方案_第1张图片


禁用后:

ActiveMQ InactivityIOException: Channel was inactive for too (>30000) long 处理方案_第2张图片



你可能感兴趣的:(Java,开发)