生産伺服器上,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:[email protected]: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)
測試如下
改之前:
禁用後: