---
title: "activeMQ安装、配置"
author: "showlike"
date: "2014-01-06T19:33:28Z"
tags: []
categories: ["开源软件"]
slug: "activemq"
draft: false
lastmod: "2014-01-06T20:07:03Z"
id: 2000105
url: "https://showlike.iteye.com/blog/2000105"
---

[**activeMQ下载地址**](http://activemq.apache.org/download.html)
[**activeMQ老版本下载地址**](http://activemq.apache.org/download-archives.html)

**<span style="color:orange">如下配置针对activeMQ5.6</span>**

**一、解压至安装目录**
**目录结构如下：**

|bin|运行脚本目录
|conf|配置文件目录
|data|消息数据保存目录
|doc|说明文档目录
|example|运行实例目录
|lib|JAR包目录
|webapps|自带管理后台目录


**二、配置**
切换至activeMQ解压目录进入conf
**2.1、管理后台登陆用户名、密码配置**
    ActiveMQ使用的是jetty服務器, 5.8 之前 console 默認密碼不開启,5.8之後秘密默認開启

打開conf/jetty.xml文件，找到


```java
<bean id="securityConstraint" class="org.eclipse.jetty.http.security.Constraint">
        <property name="name" value="BASIC" />
        <property name="roles" value="admin" />
        <property name="authenticate" value="false" />
</bean>
```


將property name为authenticate的屬性value="false" 改为"true"，
控制台的登錄用戶名密碼保存在conf/jetty-realm.properties文件中,內容如下:

```java

# Defines users that can access the web (console, demo, etc.)
# username: password [,rolename ...]
admin: admin, admin
```


注：用戶名和密碼的格式如下
用戶名 : 密碼 ,角色名 

**2.2、broker连接用户名、密码配置**
**2.2.1、加载连接用户名、密码配置文件(5.6默认已有，配置在broker节点元素内)**

```java

    <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
        <property name="locations">
            <value>file:${activemq.conf}/credentials.properties</value>
        </property>
    </bean>

```


**2.2.2、增加加载验证插件(配置在broker节点元素内)**

```java

		<plugins>   
			<simpleAuthenticationPlugin>   
				<users>   
					<authenticationUser username="${activemq.username}" password="${activemq.password}" groups="users,admins"/>   
				</users>   
			</simpleAuthenticationPlugin>   
		</plugins>

```


**2.2.3、打开conf/credentials.properties,添加用户名和密码,如下所示：**

```java

activemq.username=admin
activemq.password=showlike

```


**三、启动activeMQ**
切换至 安装目录/bin/ 双击activemq.bat运行，如运行正常将看到如下命令窗口：
![](http://dl.iteye.com/upload/picture/pic/129113/61129319-d7ef-3b5a-bcf3-d46cdb49d469.jpg)

**四、activeMQ监控**
管理后台(如2.1步骤配置成功，打开如下链接将提示输入用户名和密码)
![](http://dl.iteye.com/upload/picture/pic/129115/80077134-7cc6-3eff-a958-e90ef3e6df75.jpg)
admin：[http://127.0.0.1:8161/admin/](http://127.0.0.1:8161/admin/)


运行实例
demo：[http://127.0.0.1:8161/demo/](http://127.0.0.1:8161/demo/)

各种配置参考：[https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/ActiveMQ/page/AMQ%E5%AE%89%E5%85%A8%E6%A0%A1%E9%AA%8C%E5%8F%8AAMQ+Console%E5%AE%89%E5%85%A8%E8%AE%A4%E8%AF%81](https://www.ibm.com/developerworks/community/wikis/home?lang=en#!/wiki/ActiveMQ/page/AMQ%E5%AE%89%E5%85%A8%E6%A0%A1%E9%AA%8C%E5%8F%8AAMQ+Console%E5%AE%89%E5%85%A8%E8%AE%A4%E8%AF%81)