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.<init>(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添加以下红色参数:

<destinationPolicy>
            <policyMap>
              <policyEntries>
                <policyEntry topic=">" gcInactiveDestinations="true" inactiveTimoutBeforeGC="30000">
                  <pendingMessageLimitStrategy>
                    <constantPendingMessageLimitStrategy limit="1000"/>
                  </pendingMessageLimitStrategy>
                </policyEntry>
              </policyEntries>
            </policyMap>
</destinationPolicy>

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

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

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值