ActiveMQ消息队列过多导致客户端连接失败

一、异常描述

jvm 1    | Exception in thread "ActiveMQ BrokerService[localhost] Task-997" java.lang.OutOfMemoryError: unable to create new native thread
jvm 1    |      at java.lang.Thread.start0(Native Method)
jvm 1    |      at java.lang.Thread.start(Unknown Source)
jvm 1    |      at org.apache.activemq.thread.DedicatedTaskRunner.(DedicatedTaskRunner.java:51)
jvm 1    |      at org.apache.activemq.thread.TaskRunnerFactory.createTaskRunner(TaskRunnerFactory.java:140)
jvm 1    |      at org.apache.activemq.broker.TransportConnection.start(TransportConnection.java:1067)
jvm 1    |      at org.apache.activemq.broker.TransportConnector$1$1.run(TransportConnector.java:218)
jvm 1    |      at java.lang.Thread.run(Unknown Source)

jvm 1    | ERROR | Could not accept connection  : org.apache.activemq.transport.tcp.ExceededMaximumConnectionsException: Exceeded the maximum number of allowed
client connections. See the 'maximumConnections' property on the TCP transport configuration URI in the ActiveMQ configuration file (e.g., activemq.xml)

二、问题排查

消息队列堆积太多,导致jvm内存不足,浏览器访问mq后台管理页面发现有很多无用的消息队列

三、解决方式

配置自动清除无用的消息队列,打开activemq.xml文件(\apache-activemq-5.14.3\conf\activemq.xml),broker节点添加schedulePeriodForDestinationPurge="10000"
broker节点下的destinationPolicy添加以下红色参数:


            
              
                
                  
                    
                  
                
              
            

参数含义:
schedulePeriodForDestinationPurge:10000 每十秒检查一次,默认为0,此功能关闭
gcInactiveDestinations: true 删除掉不活动队列,默认为false
inactiveTimoutBeforeGC:30000 不活动30秒后删除,默认为60秒

配置后,重启mq服务器即可

你可能感兴趣的:(activeMQ)