I'm trying to get mbeans of Kafka using Java code ( consumer or producer ) like they appear in jconsole
In jconsole I can see the name of the mbean ( like : objetName:kafka.consumer:type=consumer-fetch-manager-metrics,client-id=consumer-1
)
so here is my code :
JMXServiceURL("service:jmx:rmi:///jndi/rmi://localhost:9998/jmxrmi");
where port is like in the config file ( server.properties
) that I set (I set port in Kafka config file ( SET JMX_PORT=9098 )
, I also tried to use my Kafka port ( 9092) but than I get address in use -
bean=new ObjectName("kafka.consumer:type=consumer-coordinator-metrics,client-id=consumer-1");
MBeanInfo info= connection.getMBeanInfo(bean);
I get InstanceNotFoundException
when I use this code :
domains=connection.getDomains();
I get all the domains except kafka.consumer ( i.e java.nio,java.util.logging , java.lang
.. etc )
but not the kafka.server
even though I can see the kafka.consumer
mbeans in Jconsole ..
but, I don't know how to access the JMXServiceURL: I tried to give the folloiwing : new
I also tries this :
MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();
but after I get the server bean , I cannot see Kafka mbeans (just other custom mbeans that i created or others but not Kafka mbeans )
I think that Kafka exposes the port to jconsole in some port which I cannot figure it
Any ideas ?