刪除不活動的隊列(Delete Inactive Destinations)
一般情況下,ActiveMQ的queue在不使用之後,可以通過web控制檯或是JMX方式來刪除掉。
當然,也可以通過配置,使得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創建頻繁的情況下,本功能非常有用。