spring - Accessing JMX MBean from Java and executing routines -


i have object named exob has multiple routines. exob spring bean , want execute routine named routine1 takes string parameter. have written code till now:

import javax.management.remote.jmxconnector; import javax.management.remote.jmxconnectorfactory; import javax.management.remote.jmxserviceurl; import javax.management.mbeanserverconnection; import javax.management.objectname;  jmxserviceurl url = new jmxserviceurl("url"); jmxconnector jmxc = jmxconnectorfactory.connect(url, null); mbeanserverconnection mbsc = jmxc.getmbeanserverconnection(); objectname mbeanname = new objectname("com.example.package:service=exob"); object  params[] = {"str"}; string  sig[] = {string.class.getname()}; mbsc.invoke(mbeanname,"routine1",params,sig); jmxc.close(); 

i using intellij , shows error @ invoke() method cannot resolve symbol routine1. way in have written code above wrong? how can access jmx mbean , invoke function inside it?

i wanted know if above approach invoke function inside mbean appropriate or if there better way it?

update: when execute above code nothing happens , execution seems hanged while running it

also when add following above code:

set<objectname> names = new treeset<objectname>(mbsc.querynames(null, null)); (objectname name : names) {   system.out.println("\tobjectname = " + name); } 

i output

objectname = com.example.package:service=exob 

this object name passing in code above when getting mbeanname. exob has routine called routine1 want invoke

javax.management package api defines 2 possible ways access mbeans. first 1 do. second one, if have java interface corresponds management interface mbean, via mbean proxy:

exobmbean exob = jmx.newmbeanproxy(mbs, name, exobmbean.class); exob.routine1(); 

the docs says: using mbean proxy convenience. second example ends calling same mbeanserver operations first one.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -