1. 安装
- 解压安装包
2. 常用命令
// 启动(默认配置文件)
./activemq start
// 停止
./activemq stop
3. 配置
删除不活动的队列(Delete Inactive Destinations)
<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创建频繁的情况下,本功能非常有用。
4.broker配置
4.1 开启JMX
<!--添加 useJmx="true" -->
<broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="${activemq.data}" useJmx="true" schedulePeriodForDestinationPurge="10000">
<!--修改 managementContext -->
<managementContext>
<managementContext createConnector="true" connectorPort="11099" />
</managementContext>
4. web控制台地址