如何通过JConsole连接到ActiveMQ Artemis?



我正在尝试通过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>

我尝试了以下方法:

  1. 文件中未注释management.xml<connector connector-port="1099"/>
  2. 未在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>
    
  3. 添加artemis-service.xml
    <argument>-Dcom.sun.management.jmxremote.rmi.port=1099</argument>
    

我刚刚通过执行以下操作在ActiveMQ Artemis 2.6.2中工作:

  1. 下载并解压缩 ActiveMQ Artemis 2.6.2 到<ACTIVEMQ_HOME>
  2. 打开终端并运行cd <ACTIVEMQ_HOME>/bin
  3. 使用./artemis create ~/testJMX --user myUser --pass myPass --require-login创建新的代理实例
  4. 取消注释<connector connector-port="1099"/>etc/management.xml中。
  5. 使用./artemis run启动代理
  6. 使用jconsole命令启动 JConsole。
  7. 将JConsole指向service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi分别使用myUsermyPass作为用户名和密码。
  8. 观察 JConsole 连接是否正确,并且所有 MBean 都可以访问。

我在Linux上使用JDK 1.8。我没有可以测试的Windows盒子。

也可以通过稍微更改步骤#4和#7来使其工作:

  1. 下载并解压缩 ActiveMQ Artemis 2.6.2 到<ACTIVEMQ_HOME>
  2. 打开终端并运行cd <ACTIVEMQ_HOME>/bin
  3. 使用./artemis create ~/testJMX --user myUser --pass myPass --require-login创建新的代理实例
  4. 删除etc/management.xmlmanagement-context元素的所有内容,以便只剩下以下内容:
    <management-context xmlns="http://activemq.org/schema" />
    
  5. 使用./artemis run启动代理
  6. 使用jconsole命令启动 JConsole。
  7. 将JConsole指向本地ActiveMQ Artemis进程
  8. 观察 JConsole 连接是否正确,并且所有 MBean 都可以访问。

通常,我建议您迁移到最新版本。ActiveMQ Artemis 2.6.2大约在3年前发布。自 2.6.2 发布以来,JMX 属性已从artemis-service.xml中删除,因为它们不再适用。有关更多详细信息,请参阅 ARTEMIS-2112。

最新更新