The call to
org.apache.activemq.artemis.api.core.management.ObjectNameBuilder#getQueueObjectName
is creating this MBean object name:

  org.apache.activemq.artemis:broker="localhost",component=
addresses,address="Step-Event",subcomponent=queues,routing-
type="anycast",queue="Step-Event"

Can you use JConsole, JVisualVM, etc. to confirm that the MBean for the
"Step-Event" queue uses this same object name?  My guess is that there's a
discrepancy here which is causing the
javax.management.InstanceNotFoundException.  If there is a discrepancy you
can likely use one of the overloaded create(..) methods
on org.apache.activemq.artemis.api.core.management.ObjectNameBuilder to
create a new ObjectNameBuilder instance and use that to call
getQueueObjectName().


Justin

On Mon, Nov 27, 2017 at 10:46 AM, alisu <alisu7...@gmail.com> wrote:

> Thanks Justin. I don't know how I missed that example earlier. It is very
> clear now after going through it. having said that, Now if I run the code
> below, I get /InstanceNotFoundException/ during serverControl.createDivert
> method invocation.
>
> /public class App {
>         private static final String JMX_URL =
> "service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi";
>         private static final String QUEUE = "Step-Event";
>
>         public static void main(final String[] args){
>                 ObjectName objName;
>                 try {
>                         objName =
> ObjectNameBuilder.DEFAULT.getQueueObjectName(SimpleString.toSimpleString(
> QUEUE),
>                                         SimpleString.toSimpleString(QUEUE),
> RoutingType.ANYCAST);
>                         HashMap env = new HashMap();
>                         String[] creds = { "admin", "admin" };
>                         env.put(JMXConnector.CREDENTIALS, creds);
>                         JMXConnector connector =
> JMXConnectorFactory.connect(new
> JMXServiceURL(JMX_URL), env);
>                         MBeanServerConnection mbean = connector.
> getMBeanServerConnection();
>                         ActiveMQServerControl serverControl =
> (ActiveMQServerControl)MBeanServerInvocationHandler.
> newProxyInstance(mbean,
> objName,
>                                         ActiveMQServerControl.class,
> false);
>                         serverControl.createDivert("non-ED", "myRoute",
> QUEUE, "tempAddress",
> false, null, null);
>                         connector.close();
>                 } catch (Exception e) {
>                         e.printStackTrace();
>                 }
>
>         }
> }/
>
> Below is the full printStackTrace:
>
> /javax.management.InstanceNotFoundException:
> org.apache.activemq.artemis:broker="localhost",component=
> addresses,address="Step-Event",subcomponent=queues,routing-
> type="anycast",queue="Step-Event"
>         at
> com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getMBean(
> DefaultMBeanServerInterceptor.java:1095)
>         at
> com.sun.jmx.interceptor.DefaultMBeanServerInterceptor.getClassLoaderFor(
> DefaultMBeanServerInterceptor.java:1444)
>         at
> com.sun.jmx.mbeanserver.JmxMBeanServer.getClassLoaderFor(
> JmxMBeanServer.java:1324)
>         at
> javax.management.remote.rmi.RMIConnectionImpl$6.run(
> RMIConnectionImpl.java:1365)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at
> javax.management.remote.rmi.RMIConnectionImpl.getClassLoaderFor(
> RMIConnectionImpl.java:1362)
>         at
> javax.management.remote.rmi.RMIConnectionImpl.invoke(
> RMIConnectionImpl.java:813)
>         at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>         at
> sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:
> 62)
>         at
> sun.reflect.DelegatingMethodAccessorImpl.invoke(
> DelegatingMethodAccessorImpl.java:43)
>         at java.lang.reflect.Method.invoke(Method.java:498)
>         at sun.rmi.server.UnicastServerRef.dispatch(
> UnicastServerRef.java:357)
>         at sun.rmi.transport.Transport$1.run(Transport.java:200)
>         at sun.rmi.transport.Transport$1.run(Transport.java:197)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at sun.rmi.transport.Transport.serviceCall(Transport.java:196)
>         at sun.rmi.transport.tcp.TCPTransport.handleMessages(
> TCPTransport.java:568)
>         at
> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(
> TCPTransport.java:826)
>         at
> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$
> 0(TCPTransport.java:683)
>         at java.security.AccessController.doPrivileged(Native Method)
>         at
> sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run(
> TCPTransport.java:682)
>         at
> java.util.concurrent.ThreadPoolExecutor.runWorker(
> ThreadPoolExecutor.java:1149)
>         at
> java.util.concurrent.ThreadPoolExecutor$Worker.run(
> ThreadPoolExecutor.java:624)
>         at java.lang.Thread.run(Thread.java:748)
>         at
> sun.rmi.transport.StreamRemoteCall.exceptionReceivedFromServer(
> StreamRemoteCall.java:276)
>         at
> sun.rmi.transport.StreamRemoteCall.executeCall(StreamRemoteCall.java:253)
>         at sun.rmi.server.UnicastRef.invoke(UnicastRef.java:162)
>         at com.sun.jmx.remote.internal.PRef.invoke(Unknown Source)
>         at javax.management.remote.rmi.RMIConnectionImpl_Stub.invoke(
> Unknown
> Source)
>         at
> javax.management.remote.rmi.RMIConnector$RemoteMBeanServerConnection.
> invoke(RMIConnector.java:1022)
>         at
> javax.management.MBeanServerInvocationHandler.invoke(
> MBeanServerInvocationHandler.java:298)
>         at com.sun.proxy.$Proxy3.createDivert(Unknown Source)
>         at artemis.management.App.main(App.java:37)
> /
>
> Any thoughts? I can confirm that the queue 'Step-Event' do exist.
>
>
>
> --
> Sent from: http://activemq.2283324.n4.nabble.com/ActiveMQ-User-
> f2341805.html
>

Reply via email to