4.10. JMX 管理の変更
JBoss EAP 6 の HornetQ コンポーネントは独自の JMX 管理を提供しましたが、それは推奨されず、今回非推奨となったため、サポート対象外になりました。JBoss EAP 6 でこの機能に依存していた場合、EAP 7 で提供される JBoss EAP 管理 CLI または JMX 管理のいずれかを使用するよう、管理ツールを移行する必要があります。
また、クライアントライブラリーをアップグレードして、JBoss EAP 7 に同梱される jboss-client.jar
を使用する必要もあります。
以下は、JBoss EAP 6 で使用された HornetQ JMX 管理コードの例になります。
JMXConnector connector = null; try { HashMap environment = new HashMap(); String[] credentials = new String[]{"admin", "Password123!"}; environment.put(JMXConnector.CREDENTIALS, credentials); // HornetQ used the protocol "remoting-jmx" and port "9999" JMXServiceURL beanServerUrl = new JMXServiceURL("service:jmx:remoting-jmx://127.0.0.1:9990"); connector = JMXConnectorFactory.connect(beanServerUrl, environment); MBeanServerConnection mbeanServer = connector.getMBeanServerConnection(); // The JMX object name pointed to the HornetQ JMX management ObjectName objectName = new ObjectName("org.hornetq:type=Server,module=JMS"); // The invoked method name was "listConnectionIDs" String[] connections = (String[]) mbeanServer.invoke(objectName, "listConnectionIDs", new Object[]{}, new String[]{}); for (String connection : connections) { System.out.println(connection); } } finally { if (connector != null) { connector.close(); } }
以下は、JBoss EAP 7 の ActiveMQ Artemis に必要な同等のコード例になります。
JMXConnector connector = null; try { HashMap environment = new HashMap(); String[] credentials = new String[]{"admin", "Password123!"}; environment.put(JMXConnector.CREDENTIALS, credentials); // ActiveMQ Artemis uses the protocol "remote+http" and port "9990" JMXServiceURL beanServerUrl = new JMXServiceURL("service:jmx:remote+http://127.0.0.1:9990"); connector = JMXConnectorFactory.connect(beanServerUrl, environment); MBeanServerConnection mbeanServer = connector.getMBeanServerConnection(); // The JMX object name points to the new JMX management in the `messaging-activemq` subsystem ObjectName objectName = new ObjectName("jboss.as:subsystem=messaging-activemq,server=default"); // The invoked method name is now "listConnectionIds" String[] connections = (String[]) mbeanServer.invoke(objectName, "listConnectionIds", new Object[]{}, new String[]{}); for (String connection : connections) { System.out.println(connection); } } finally { if (connector != null) { connector.close(); } }
新しい実装ではメソッド名とパラメーターが変更されたことに注意してください。以下の手順に従うと、JConsole で新しいメソッド名を検索できます。
以下のコマンドを使用して JConsole に接続します。
$ EAP_HOME/bin/jconsole.sh
- JBoss EAP のローカルプロセスに接続します。「jboss-modules.jar」で始まることに注意してください。
- MBeans タブで jboss.as → messaging-activemq → default → Operations の順に選択し、メソッド名と属性のリストを表示します。