备注:(删除不活动的队列(Delete Inactive Destinations))
一般情况下,ActiveMQ的Topic和Queue在不使用之后,可以通过web控制台或是JMX方式来删除掉。
当然,也可以通过配置,使得broker可以自动探测到无用的队列(一定时间内为空的队列)并删除掉,回收响应资源。
实现定时自动清理无效的Topic和Queue需要设置三个属性。
activemq.xml配置如下:
在<broker>节点上新增:
-
<broker xmlns="http://activemq.apache.org/schema/core" schedulePeriodForDestinationPurge="10000">
-
<destinationPolicy>
-
<policyMap>
-
<policyEntries>
-
<policyEntry queue=">" gcInactiveDestinations="true" inactiveTimoutBeforeGC="30000"/>
-
</policyEntries>
-
</policyMap>
-
</destinationPolicy>
-
</broker>
schedulePeriodForDestinationPurge:10000 每十秒检查一次,默认为0,此功能关闭
gcInactiveDestinations: true 删除掉不活动队列,默认为false
inactiveTimoutBeforeGC:30000 不活动30秒后删除,默认为60秒
由于ActiveMQ使用时自动创建Destination,并且默认情况下不会删除掉,这种只增加不减少,导致在queue创建频繁的情况下,本功能非常有用。
http://activemq.apache.org/delete-inactive-destinations.html
activemq定时不起作用添加相关属性
ActiveMQ from version 5.4 has an optional persistent scheduler built into the ActiveMQ message broker. It is enabled by setting the broker schedulerSupport attribute to true in the xml configuration.
意思是说要在mq的xml配置文件中,broker节点处加入schedulerSupport属性,才能使mq的任务计划生效,于是,我尝试加入该属性修改activemq.xml 在<broker>里添加属性schedulerSupport="true" 重启mq后果然生效了。
网上大部人只把如果设置参数翻译过来了,但是不说如何配置,这对于我们这些菜鸟小白来说真的伤不起呀。在这个地方纠结了好久。