如何通过 JMX 以编程方式连接到 AMQ7 以使用 MBean 获取代理指标?
How do I connect to AMQ7 via JMX, programmatically to get broker metrics with MBean?
我们的团队刚刚开始测试 AMQ7,自从我们从 AMQ6 迁移到 AMQ7 后,我实现的应用程序不再连接到代理。阅读文档后,我注意到 uri 字符串与之前完全不同,它不需要嵌入 uri 的服务或 rmi 进行连接。下面是我用来连接但导致错误的代码。
java.net.MalformedURLException: Service URL must start with service:jmx:
at java.management/javax.management.remote.JMXServiceURL.<init>(JMXServiceURL.java:169) ~[na:na]
at com.ups.aaa.doss.MsgAudtingRunner.run(MsgAudtingRunner.java:110) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:567) ~[na:na]
at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84) ~[spring-context-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) ~[spring-context-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:93) ~[spring-context-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[na:na]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
at java.base/java.lang.Thread.run(Thread.java:830) ~[na:na]
这是错误发生的代码:
JMXServiceURL url = new JMXServiceURL(brkerInfo.getValue());
JMXConnector connector = JMXConnectorFactory.connect(url, environment);
是否有另一个 Class 我需要引用而不是 JMXServiceURL,我知道它期望 uri 将服务作为前缀。
查看 examples/features/standard/jmx
(also available in GitHub) 中的代理附带的示例。它演示了如何使用 JMX 以编程方式连接到代理。事实上,它确实使用了 JMXServiceURL
和 JMXConnectorFactory
,而 URL 确实使用了“service”和“rmi”,例如:
service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi
我们的团队刚刚开始测试 AMQ7,自从我们从 AMQ6 迁移到 AMQ7 后,我实现的应用程序不再连接到代理。阅读文档后,我注意到 uri 字符串与之前完全不同,它不需要嵌入 uri 的服务或 rmi 进行连接。下面是我用来连接但导致错误的代码。
java.net.MalformedURLException: Service URL must start with service:jmx:
at java.management/javax.management.remote.JMXServiceURL.<init>(JMXServiceURL.java:169) ~[na:na]
at com.ups.aaa.doss.MsgAudtingRunner.run(MsgAudtingRunner.java:110) ~[classes/:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:na]
at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:na]
at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:na]
at java.base/java.lang.reflect.Method.invoke(Method.java:567) ~[na:na]
at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:84) ~[spring-context-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) ~[spring-context-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at org.springframework.scheduling.concurrent.ReschedulingRunnable.run(ReschedulingRunnable.java:93) ~[spring-context-5.0.9.RELEASE.jar:5.0.9.RELEASE]
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515) ~[na:na]
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264) ~[na:na]
at java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128) ~[na:na]
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628) ~[na:na]
at java.base/java.lang.Thread.run(Thread.java:830) ~[na:na]
这是错误发生的代码:
JMXServiceURL url = new JMXServiceURL(brkerInfo.getValue());
JMXConnector connector = JMXConnectorFactory.connect(url, environment);
是否有另一个 Class 我需要引用而不是 JMXServiceURL,我知道它期望 uri 将服务作为前缀。
查看 examples/features/standard/jmx
(also available in GitHub) 中的代理附带的示例。它演示了如何使用 JMX 以编程方式连接到代理。事实上,它确实使用了 JMXServiceURL
和 JMXConnectorFactory
,而 URL 确实使用了“service”和“rmi”,例如:
service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi