ActiveMQ的安装及实例运行

12年前

本文主要介绍了ActiveMQWindow OS上的安装以及安装完成后的运行实例。

一、安装过程

1、  下载ActiveMQ

http://activemq.apache.org/download.html 上下载对应版本及OSActiveMQ。目前最新的版本是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