1.環境
-
win8
-
JDK1.7,配置環境變量
-
apache-activemq-5.10.1-bin.zip
AMQ下載地址 http://activemq.apache.org/download-archives.html
2.安裝
把apache-activemq-5.10.1-bin.zip解壓到一個目錄下,例如D:\MQ\apache-activemq\apache-activemq-5.10.1。
目錄結構介紹如下。
-
bin,放置啓動、停止、註冊服務等命令文件。
-
conf,配置文件,包括broker、jetty、log等配置文件。
-
data,放置消息緩存(kahadb)、jetty中jsp編譯後的class、AMQ日誌等文件。
-
docs,幫助文檔
-
examples,應用示例
-
lib,依賴的jar包
-
webapps,AMQ下的web應用,包括web console 和 file server。
-
webapps-demo,demo應用,默認不能訪問,如需訪問需要在conf/jetty.xml文件中配置。
-
activemq-all-5.10.1.jar, AMQ的開發用的jar包
-
其它文件,包括license、notice和 readme
3.配置
配置文件都在conf文件夾下,主要有activemq.xml、jetty.xml和log4j.properties。
-
配置broker的端口,修改activemq.xml中下面的端口號
1
2
3
4
5
6
7
8
|
< transportConnectors > <!-- DOS protection, limit concurrent connections to 1000 and frame size to 100MB --> < transportConnector name = "openwire" uri = "tcp://0.0.0.0:61616?maximumConnections=1000&wireFormat.maxFrameSize=104857600" /> < transportConnector name = "amqp" uri = "amqp://0.0.0.0:5672?maximumConnections=1000&wireFormat.maxFrameSize=104857600" /> < transportConnector name = "stomp" uri = "stomp://0.0.0.0:61613?maximumConnections=1000&wireFormat.maxFrameSize=104857600" /> < transportConnector name = "mqtt" uri = "mqtt://0.0.0.0:1883?maximumConnections=1000&wireFormat.maxFrameSize=104857600" /> < transportConnector name = "ws" uri = "ws://0.0.0.0:61614?maximumConnections=1000&wireFormat.maxFrameSize=104857600" /> </ transportConnectors > |
-
配置jetty的端口,修改jetty.xml中的下面內容。
1
2
3
4
5
|
< bean id = "jettyPort" class = "org.apache.activemq.web.WebConsolePort" init-method = "start" > <!-- the default port number for the web console --> < property name = "host" value = "0.0.0.0" /> < property name = "port" value = "8161" /> </ bean > |
配置啓動demo工程,在jetty.xml中找到org.eclipse.jetty.webapp.WebAppContext,增加下面的內容。
1
2
3
4
5
|
< bean class = "org.eclipse.jetty.webapp.WebAppContext" > < property name = "contextPath" value = "/demo" /> < property name = "resourceBase" value = "${activemq.home}/webapps-demo/demo" /> < property name = "logUrlOnStart" value = "true" /> </ bean > |
4. 啓動和停止
在cmd窗口中進入D:\MQ\apache-activemq\cluster\amq2\bin>目錄,
輸入activemq.bat start ,啓動AMQ。
AMQ的默認使用的TCP連接端口是61616,可以通過命令 netstat -an|find "61616" 來測試是否啓動。
輸入ctrl + c 或者使用activemq stop命令,停止AMQ。
5.監控
ActiveMQ內置了jetty服務器,提供了admin 和demo 兩個工程,admin工程是管理控制檯。
管理控制檯地址:http://localhost:8161/admin 用戶名密碼都是admin
demo地址:http://localhost:8161/demo 默認不啓動,需要在jetty中配置