无法通过 JMX 在 ActiveMQ Artemis 中接收消息。

huangapple go评论69阅读模式
英文:

Can't receive messages in ActiveMQ Artemis through the JMX

问题

I'm trying to get messages from the queue through the JMX, but it gives me an error:

Exception in thread "main" java.lang.reflect.UndeclaredThrowableException
	at com.sun.proxy.$Proxy6.getBrokerId(Unknown Source)
	at jmxClientUIPConsole.JMXExample.main(JMXExample.java:93)
Caused by: javax.management.InstanceNotFoundException: org.apache.activemq:type=Broker,brokerName=localhost
	at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1083)
	...

Code ObjectName:

ObjectName mbeanNameQueue = new ObjectName("org.apache.activemq:type=Broker,brokerName=static-broker1,destinationType=Queue,destinationName=tmp_queue2");
org.apache.activemq.broker.jmx.QueueViewMBean queueView = JMX.newMBeanProxy(mbsc, mbeanNameQueue, org.apache.activemq.broker.jmx.QueueViewMBean.class);
System.out.println(queueView.browseAsTable());

Using version:

<dependency>
    <groupId>org.apache.activemq</groupId>
    <artifactId>activemq-broker</artifactId>
    <version>5.8.0</version>
</dependency>

Tried to enter in ObjectName: org.apache.activemq:type=Broker,brokerName=localhost and org.apache.activemq:BrokerName=localhost,Type=Broker

英文:

I'm trying to get messages from the queue through the JMX, but it gives me an error

Exception in thread &quot;main&quot; java.lang.reflect.UndeclaredThrowableException
	at com.sun.proxy.$Proxy6.getBrokerId(Unknown Source)
	at jmxClientUIPConsole.JMXExample.main(JMXExample.java:93)
Caused by: javax.management.InstanceNotFoundException: org.apache.activemq:type=Broker,brokerName=localhost
	at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(DefaultMBeanServerInterceptor.java:1083)
	at java.management/com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBeanInfo(DefaultMBeanServerInterceptor.java:1353)
	at java.management/com.sun.jmx.mbeanserver.JmxMBeanServer.getMBeanInfo(JmxMBeanServer.java:920)
	at java.base/jdk.internal.reflect.GeneratedMethodAccessor6.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at org.apache.activemq.artemis.core.server.management.ArtemisMBeanServerBuilder$MBeanInvocationHandler.invoke(ArtemisMBeanServerBuilder.java:96)
	at com.sun.proxy.$Proxy30.getMBeanInfo(Unknown Source)
	at org.apache.activemq.artemis.core.server.management.ArtemisMBeanServerGuard.handleGetAttribute(ArtemisMBeanServerGuard.java:77)
	at org.apache.activemq.artemis.core.server.management.ArtemisMBeanServerGuard.invoke(ArtemisMBeanServerGuard.java:62)
	at org.apache.activemq.artemis.core.server.management.ArtemisMBeanServerBuilder$MBeanInvocationHandler.invoke(ArtemisMBeanServerBuilder.java:76)
	at com.sun.proxy.$Proxy30.getAttribute(Unknown Source)
	at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.doOperation(RMIConnectionImpl.java:1443)
	at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl$PrivilegedOperation.run(RMIConnectionImpl.java:1307)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.doPrivilegedOperation(RMIConnectionImpl.java:1406)
	at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl.getAttribute(RMIConnectionImpl.java:637)
	at java.base/jdk.internal.reflect.GeneratedMethodAccessor10.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:566)
	at java.rmi/sun.rmi.server.UnicastServerRef.dispatch(UnicastServerRef.java:359)
	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:200)
	at java.rmi/sun.rmi.transport.Transport$1.run(Transport.java:197)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.rmi/sun.rmi.transport.Transport.serviceCall(Transport.java:196)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport.handleMessages(TCPTransport.java:562)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(TCPTransport.java:796)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(TCPTransport.java:677)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.rmi/sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(TCPTransport.java:676)
	at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
	at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
	at java.base/java.lang.Thread.run(Thread.java:834)
	at java.rmi/sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(StreamRemoteCall.java:303)
	at java.rmi/sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:279)
	at java.rmi/sun.rmi.server.UnicastRef.invoke(UnicastRef.java:164)
	at jdk.remoteref/jdk.jmx.remote.internal.rmi.PRef.invoke(Unknown Source)
	at java.management.rmi/javax.management.remote.rmi.RMIConnectionImpl_Stub.getAttribute(Unknown Source)
	at java.management.rmi/javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.getAttribute(RMIConnector.java:904)
	at java.management/javax.management.MBeanServerInvocationHandler.invoke(MBeanServerInvocationHandler.java:273)
	... 2 more

Code ObjectName:

ObjectName mbeanNameQueue = new ObjectName(&quot;org.apache.activemq:type=Broker,brokerName=static-broker1,destinationType=Queue,destinationName=tmp_queue2&quot;);
            org.apache.activemq.broker.jmx.QueueViewMBean queueView = JMX.newMBeanProxy(mbsc, mbeanNameQueue, org.apache.activemq.broker.jmx.QueueViewMBean.class);
            System.out.println(queueView.browseAsTable());

Using verion:

&lt;dependency&gt;
            &lt;groupId&gt;org.apache.activemq&lt;/groupId&gt;
            &lt;artifactId&gt;activemq-broker&lt;/artifactId&gt;
            &lt;version&gt;5.8.0&lt;/version&gt;
        &lt;/dependency&gt;

Tried to enter in ObjectName: org.apache.activemq:type=Broker,brokerName=localhost and org.apache.activemq:BrokerName=localhost,Type=Broker

答案1

得分: 1

这是翻译好的内容:

看起来你正在尝试在ActiveMQ Artemis中使用ActiveMQ "Classic"中的JMX MBean ObjectNames。这是行不通的。ActiveMQ Artemis中的管理API与ActiveMQ "Classic"不同。

你可以在文档中找到关于ActiveMQ Artemis管理API的一般信息。要了解更多关于各种可用管理操作的信息,请参阅这些接口的Javadoc。它们位于org.apache.activemq.artemis.api.core.management包中,它们的名称以Control结尾(例如,ServerControlQueueControl等)。

在你的情况下,你可能想要使用QueueControl上的browse()操作

英文:

It appears you're attempting to use JMX MBean ObjectNames from ActiveMQ "Classic" in ActiveMQ Artemis. That won't work. The management API in ActiveMQ Artemis is different from ActiveMQ "Classic."

You can find general information about the ActiveMQ Artemis management API in the documentation. To learn more about the various available management operations, see the Javadoc for these interfaces. They are located in the org.apache.activemq.artemis.api.core.management package and they are named with the word Control at the end (e.g. ServerControl, QueueControl, etc.).

In your case, you'll probably want to use the browse() operation on the QueueControl.

huangapple
  • 本文由 发表于 2023年4月19日 18:55:46
  • 转载请务必保留本文链接:https://go.coder-hub.com/76053674.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定