其他分享
首页 > 其他分享> > ActiveMQ由于消费能力不够定时清除的策略

ActiveMQ由于消费能力不够定时清除的策略

作者:互联网

在使用ActiveMQ的过程中,经常会发生生产者和消费者不对称而导致的消费能力过剩的问题,这时就需要我们定时清除消息,需要在ActiveMQ服务的机器上找到相对应的ActiveMQ.xml配置文件,加上如下配置即可:

<broker xmlns="http://activemq.apache.org/schema/core" schedulePeriodForDestinationPurge="10000">
    <destinationPolicy>
       <policyMap>
          <policyEntries>
             <policyEntry queue=">" gcInactiveDestinations="true" inactiveTimoutBeforeGC="30000"/>
          </policyEntries>
       </policyMap>
    </destinationPolicy>     
  </broker>

  

实现定时自动清理无效的Topic和Queue需要设置三个属性。
schedulePeriodForDestinationPurge执行清理任务的周期,
gcInactiveDestinations="true"启用清理功能
 inactiveTimoutBeforeGC="30000" Topic或Queue超时时间
在规定的时间内,无有效订阅,没有入队记录,超时后就会被清理

标签:inactiveTimoutBeforeGC,30000,清除,清理,gcInactiveDestinations,定时,ActiveMQ
来源: https://www.cnblogs.com/zunzunQ/p/11411921.html