ActiveMQ學習筆記(二)--安裝ActiveMQ

一、Windows安裝AMQ

步驟一:把apache-activemq-5.13.0-bin.zip解壓到一個目錄下,例如D:\MQ\apache-activemq\apache-activemq-5.13.0。

目錄結構介紹如下。

wKioL1e1fYiDsFkUAAB62TeZEHE358.png


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.13.0.jar, AMQ的開發用的jar包


其它文件,包括license、notice和 readme

步驟二:配置。配置文件都在conf文件下,主要有activemq.xml、jetty.xml和log4j.properties.

    1.配置broker的端口,修改activema.xml中的端口號

<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&amp;wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="amqp" uri="amqp://0.0.0.0:5672?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="stomp" uri="stomp://0.0.0.0:61613?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="mqtt" uri="mqtt://0.0.0.0:1883?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
            <transportConnector name="ws" uri="ws://0.0.0.0:61614?maximumConnections=1000&amp;wireFormat.maxFrameSize=104857600"/>
        </transportConnectors>

    2.配置jetty的端口和配置啓動demo,修改jetty.xml中的內容

<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>
    
<bean class="org.eclipse.jetty.webapp.WebAppContext">
					<property name="contextPath" value="/demo" />
					<property name="resourceBase" value="${activemq.home}/webapps/api" />
					<property name="logUrlOnStart" value="true" />
				</bean>
				<bean class="org.eclipse.jetty.server.handler.ResourceHandler">
					<property name="directoriesListed" value="false" />
					<property name="welcomeFiles">
						<list>
							<value>index.html</value>
						</list>
					</property>
					<property name="resourceBase" value="${activemq.home}/webapps/" />
				</bean>

    3.啓動和停止

    進入amq安裝目錄的bin目錄下,運行activemq.bat文件,啓動AMQ。AMQ默認使用TCP連接端口61616,可以通過命令netstat -an|find "61616"來測試是否啓動,輸入Ctrl+ C或者使用activemq stop命令,停止AMQ。

    4.監控

    

    ActiveMQ內置了jetty服務器,提供了admin 和demo 兩個工程,admin工程是管理控制檯。

    管理控制檯地址:http://localhost:8161/admin     用戶名密碼都是admin

    demo地址:http://localhost:8161/demo  默認不啓動,需要在jetty中配置

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章