---
title: "activeMQ JMS监控配置"
author: "showlike"
date: "2014-01-07T09:02:52Z"
tags: []
categories: ["开源软件"]
slug: "activemq-jms"
draft: false
lastmod: "2014-01-06T21:08:00Z"
id: 2000126
url: "https://showlike.iteye.com/blog/2000126"
---

**一、配置activeMQ**
<span style="color:orange">切换至 activemq解压目录/conf/</span>
**1、修改conf/中的activemq.xml，如下**

```java

    <broker xmlns="http://activemq.org/config/1.0" brokerName="localhost" useJmx="true">  
      
      ...  
      
      <managementContext>  
         <managementContext createConnector="false"/>  
      </managementContext>  
      
      ...  
      
    </broker>  

```

<span style="color:orange">
useJmx="true" : 启用JMX
createConnector="false" :　不自创建连接</span>

**2、修改jmx.access和jmx.password，配置添加JMS登陆用户和密码**
<span style="color:brown">jmx.access</span>

```java

# The "monitorRole" role has readonly access.  
# The "controlRole" role has readwrite access.  
monitorRole readonly  
controlRole readwrite 

```


<span style="color:brown">jmx.password</span>

```java

# The "monitorRole" role has password "abc123".   
# The "controlRole" role has password "abcd1234".  
monitorRole abc123  
controlRole abcd1234  

```


**3、打开activemq解压目录/bin/activemq.bat 编辑，将：**

```java

if "%SUNJMX%" == "" set SUNJMX=-Dcom.sun.management.jmxremote
REM set SUNJMX=-Dcom.sun.management.jmxremote.port=1099 -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false

```


<span style="color:olive">修改为：</span>

```java

if "%SUNJMX%" == "" set SUNJMX=-Dcom.sun.management.jmxremote.port=11099 -Dcom.sun.management.jmxremote.authenticate=true -Dcom.sun.management.jmxremote.ssl=false -Dcom.sun.management.jmxremote.password.file=%ACTIVEMQ_BASE%/conf/jmx.password -Dcom.sun.management.jmxremote.access.file=%ACTIVEMQ_BASE%/conf/jmx.access
REM set SUNJMX=-Dcom.sun.management.jmxremote

```


<span style="color:orange">注：开启远端JMX端口11099，这里的端口与activemq.xml里面配置的jmx端口号（默认是1099）不能重复。</span>

至此jms监控配置完毕

4、重启activemq
如启动activemq时，窗口一闪就显示了，当获取到如下异常：

```java

错误:必须限制口令文件读取访问权限: D:\work\apache-activemq-5.6.0\bin\../conf/jmx.password

```


<span style="color:red">解决方法：运行cmd 切换至 activemq解压目录/conf ，运行如下命令,修改访问权限：</span>

```java

cacls ../conf/jmx.password /P Administrators:R
cacls ../conf/jmx.access /P Administrators:R

```

<span style="color:orange">当提示时，输入Y</span>

至此完毕，重启activemq