ActiveMQ的安裝及實例運行
本文主要介紹了ActiveMQ在Window OS上的安裝以及安裝完成后的運行實例。
一、安裝過程
1、 下載ActiveMQ
在http://activemq.apache.org/download.html 上下載對應版本及OS的ActiveMQ。目前最新的版本是ActiveMQ5.3.1。
2、 安裝前的準備
a、 首先確保已經安裝了Jdk,并設置%JAVA_HOME%環境變量;
b、 安裝ant編譯環境,并設置%ANT_HOME%環境變量;
3、 將下載的ActiveMQ解壓后安裝放置在本地磁盤,本文放在D:/activemq下面。
4、 設置環境變量
在完成上述操作后,需要設置環境變量%ACMQ_HOME%。
至此,該ActiveMQ已經安裝完成。
二、安裝檢驗
在經過上述安裝過程后,為了確保可以正常運行,通過如下的方式進行檢驗。
在ActiveMQ的安裝目錄下
$cd bin
$activemq
出現如下信息,即表明該ActiveMQ服務器已經成功啟動。
Loading message broker from: xbean:activemq.xml
INFO | Using Persistence Adapter: org.apache.activemq.store.kahadb.KahaDBPersistenceAdapter@19fe451
INFO | Replayed 1 operations from the journal in 0.015 seconds.
INFO | ActiveMQ 5.3.0 JMS Message Broker (localhost) is starting
INFO | For help or more information please see: http://activemq.apache.org/
INFO | Listening for connections at: tcp://0.0.0.0:61616
INFO | Connector openwire Started
INFO | ActiveMQ JMS Message Broker (localhost, ID:zaniel-zhao--4547-1269405003937-0:0) started
INFO | Logging to org.slf4j.impl.JCLLoggerAdapter(org.mortbay.log) via org.mortbay.log.Slf4jLog
INFO | jetty-6.1.9
INFO | ActiveMQ WebConsole initialized.
INFO | Initializing Spring FrameworkServlet 'dispatcher'
INFO | ActiveMQ Console at http://0.0.0.0:8161/admin
INFO | Initializing Spring root WebApplicationContext
INFO | Connector vm://localhost Started
INFO | Camel Console at http://0.0.0.0:8161/camel
INFO | ActiveMQ Web Demos at http://0.0.0.0:8161/demo
INFO | RESTful file access application at http://0.0.0.0:8161/fileserver
INFO | Started SelectChannelConnector@0.0.0.0:8161
INFO | Kaha Store using data directory D:/activemq/bin/../data/localhost/tmp_storage
INFO | Slow KahaDB access: cleanup took 1063
INFO | Slow KahaDB access: cleanup took 1234
在example目錄下運行如下命令:
$cd example
$ant consumer
在運行該命令后會出現如下信息,表明消息者客戶端已經建立。
consumer:
[echo] Running consumer against server at $url = tcp://localhost:61616 for subject $subject = TEST.FOO
[java] Connecting to URL: tcp://localhost:61616
[java] Consuming queue: TEST.FOO
[java] Using a non-durable subscription
[java] We are about to wait until we consume: 2000 message(s) then we will shutdown
在另一個控制臺上運行如下命令:
$ant producer
運行該命令后會出現向隊列中發送消息,而且消費者控制臺上會有消息不斷輸出,即表明該MQ已經成功安裝,而且實例運行正確。
當然也可以運行如下的命令:
$ ant producer –Durl=tcp://127.0.0.1:61616</span>