我正在尝试通过JConsole连接到ActiveMQ Artemis。但是,它似乎不起作用。
- JDK 版本:1.8.0
- ActiveMQ Artemis版本:2.6.2
我已经尝试了以下带有和不使用用户/密码(管理员/管理员)的URL。
service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
和
service:jmx:rmi:///jndi/rmi://0.0.0.0:1099/jmxrmi
我的代理正在本地运行。我只是解压缩它并创建了一个实例。这是我management.xml
:
<management-context xmlns="http://activemq.org/schema">
<connector connector-port="1099"/>
<authorisation>
<whitelist>
<entry domain="hawtio"/>
</whitelist>
<default-access>
<access method="list*" roles="amq"/>
<access method="get*" roles="amq"/>
<access method="is*" roles="amq"/>
<access method="set*" roles="amq"/>
<access method="*" roles="amq"/>
</default-access>
<role-access>
<match domain="org.apache.activemq.artemis">
<access method="list*" roles="amq"/>
<access method="get*" roles="amq"/>
<access method="is*" roles="amq"/>
<access method="set*" roles="amq"/>
<access method="*" roles="amq"/>
</match>
<!--example of how to configure a specific object-->
<!--<match domain="org.apache.activemq.artemis" key="subcomponent=queues">
<access method="list*" roles="view,update,amq"/>
<access method="get*" roles="view,update,amq"/>
<access method="is*" roles="view,update,amq"/>
<access method="set*" roles="update,amq"/>
<access method="*" roles="amq"/>
</match>-->
</role-access>
</authorisation>
</management-context>
我尝试了以下方法:
- 文件中未注释
management.xml
<connector connector-port="1099"/>
- 未在
artemis-service.xml
中评论:<!-- uncomment this if you want to connect jconsole to connect --> <argument>-Dcom.sun.management.jmxremote</argument> <argument>-Dcom.sun.management.jmxremote.port=1099</argument> <argument>-Dcom.sun.management.jmxremote.ssl=false</argument> <argument>-Dcom.sun.management.jmxremote.authenticate=false</argument>
- 添加
artemis-service.xml
:<argument>-Dcom.sun.management.jmxremote.rmi.port=1099</argument>
我刚刚通过执行以下操作在ActiveMQ Artemis 2.6.2中工作:
- 下载并解压缩 ActiveMQ Artemis 2.6.2 到
<ACTIVEMQ_HOME>
- 打开终端并运行
cd <ACTIVEMQ_HOME>/bin
- 使用
./artemis create ~/testJMX --user myUser --pass myPass --require-login
创建新的代理实例 - 取消注释
<connector connector-port="1099"/>
在etc/management.xml
中。 - 使用
./artemis run
启动代理 - 使用
jconsole
命令启动 JConsole。 - 将JConsole指向
service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
分别使用myUser
和myPass
作为用户名和密码。 - 观察 JConsole 连接是否正确,并且所有 MBean 都可以访问。
我在Linux上使用JDK 1.8。我没有可以测试的Windows盒子。
也可以通过稍微更改步骤#4和#7来使其工作:
- 下载并解压缩 ActiveMQ Artemis 2.6.2 到
<ACTIVEMQ_HOME>
- 打开终端并运行
cd <ACTIVEMQ_HOME>/bin
- 使用
./artemis create ~/testJMX --user myUser --pass myPass --require-login
创建新的代理实例 - 删除
etc/management.xml
中management-context
元素的所有内容,以便只剩下以下内容:<management-context xmlns="http://activemq.org/schema" />
- 使用
./artemis run
启动代理 - 使用
jconsole
命令启动 JConsole。 - 将JConsole指向本地ActiveMQ Artemis进程。
- 观察 JConsole 连接是否正确,并且所有 MBean 都可以访问。
通常,我建议您迁移到最新版本。ActiveMQ Artemis 2.6.2大约在3年前发布。自 2.6.2 发布以来,JMX 属性已从artemis-service.xml
中删除,因为它们不再适用。有关更多详细信息,请参阅 ARTEMIS-2112。