ActiveMQ InactivityIOException

问题现象

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

1
2019-03-26 23:01:18,815 | WARN  | Transport Connection to: tcp://xx.xx.xx.xx:59582 failed: org.apache.activemq.transport.InactivityIOException: Channel was inactive for too (>30000) long: tcp://xx.xx.xx.xx:59582 | org.apache.activemq.broker.TransportConnection.Transport | ActiveMQ InactivityMonitor Worker

官网解释

1
2
3
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端会重连成功,但是不能发送数据,然后继续报下面异常:

1
[ WARN ]  Transport (tcp:

解决方案

1
2
设置wireFormat.maxInactivityDuration=0,禁用InactivityMonitor
改为tcp://xx.xx.xx.xx:61616?wireFormat.maxInactivityDuration=0