ActiveMQ 是Apache出品,最流行的,能力强劲的开源消息总线。ActiveMQ 是一个完全支持JMS1.1和J2EE 1.4规范的 JMS Provider实现,尽管JMS规范出台已经是很久的事情了,但是JMS在当今的J2EE应用中间仍然扮演着特殊的地位。

1安装


定义activemq安装目录为/usr/local/activemq

定义activemq数据存放目录为 /data/postmall/activemq/

cd /tmp

wget http://archive.apache.org/dist/activemq/apache-activemq/5.4.1/apache-activemq-5.4.1-bin.tar.gz

tar -zxvf apache-activemq-5.4.1-bin.tar.gz

mv activemq /usr/local/

vim /usr/local/activemq/conf/activemq.xml


<broker xmlns="http://activemq.apache.org/schema/core" brokerName="localhost" dataDirectory="/data/postmall/activemq/data" destroyApplicationContextOnStop="true">

<destinationPolicy>

<policyMap>

<policyEntries>

<policyEntry topic=">" producerFlowControl="true" memoryLimit="64mb">

<pendingSubscriberPolicy>

<vmCursor />

</pendingSubscriberPolicy>

</policyEntry>

<policyEntry queue=">" producerFlowControl="true" memoryLimit="64mb">

</policyEntry>

</policyEntries>

</policyMap>

</destinationPolicy>

<managementContext>

<managementContext createConnector="false"/>

</managementContext>

<persistenceAdapter>

<kahaPersistenceAdapter directory="/data/postmall/activemq/data" maxDataFileLength="32mb"/>

</persistenceAdapter>

<transportConnectors>

<transportConnector name="openwire" uri="tcp://0.0.0.0:61616"/>

</transportConnectors>

</broker>

<import resource="jetty.xml"/>

</beans>



2 启动ActiveMQ

/usr/local/activemq/bin/activemq setup /home/web/.activemqrc

/usr/local/activemq/bin/activemq start

检查activemq是否已经启动并查看日志是否正常

ps -ef | grep active

tail -fn 100 /usr/local/activemq/data/activemq.log

/usr/local/activemq/bin/activemq stop


 3  Activemq 启动脚本

# su - web

Web> cat activemq_61616_restart.sh

#!/bin/bash

# restart activemq port 61616

cd

/usr/local/activemq1/bin/activemq stop

if [ -f /usr/local/activemq1/data/activemq.pid ]

then

rm -f /usr/local/activemq1/data/activemq.pid

fi

sleep 5

/usr/local/activemq1/bin/activemq start