This content has been marked as final.
Show 1 reply
-
1. Re: Remote Access for Service Mbeans in Jboss 7
jaysensharma Mar 14, 2013 8:52 AM (in response to sketcha)1 of 1 people found this helpfulHI,
You can create an Register MBean using SAR archives as mentioned using "META-INF/jboss-service.xml" file in the link: http://middlewaremagic.com/jboss/?p=366
<?xml version="1.0" encoding="UTF-8"?> <server xmlns="urn:jboss:service:7.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="urn:jboss:service:7.0 jboss-service_7_0.xsd"> <mbean code="custom.mbean.MyServerMonitor" name="service.server.monitor:service=MyMonitor"> <attribute name="Frequency">5000</attribute> </mbean> </server>
Since JBossAS7.2 the legacy "ServiceMBeans" will be added which can also be used to create your Own Service MBeans see : https://issues.jboss.org/browse/AS7-887
You can use following kind of JMX Code to access MBeans deployed on JBossAS7.1 and above
import javax.management.MBeanServerConnection; import javax.management.remote.JMXConnector; import javax.management.remote.JMXConnectorFactory; import javax.management.remote.JMXServiceURL; import javax.management.*; public class TestJMXAccess { public static void main(String[] args) throws Exception { String host = "10.10.10.10"; // Your JBoss Bind Address default is localhost int port = 4447; // JBoss remoting port /* 4447 can be enabled in your JBoss Configuration file with the help of the following configuration in your JBoss configuration file <subsystem xmlns="urn:jboss:domain:jmx:1.1"> <show-model value="true"/> <remoting-connector use-management-endpoint="false" /> </subsystem> If you do not set use-management-endpoint="false" explicitly then you can access the JBoss using Native Management Port (9999) as default. */ String urlString ="service:jmx:remoting-jmx://" + host + ":" + port; System.out.println(" \n\n\t**** urlString: "+urlString); JMXServiceURL serviceURL = new JMXServiceURL(urlString); JMXConnector jmxConnector = JMXConnectorFactory.connect(serviceURL, null); MBeanServerConnection connection = jmxConnector.getMBeanServerConnection(); ObjectName objectName=new ObjectName("jboss.as:subsystem=messaging,hornetq-server=default"); Integer threadPoolMaxSize=(Integer)connection.getAttribute(objectName, "threadPoolMaxSize");
You will need to add "$JBOSS_HOME/\bin\client\jboss-client.jar" in your Client classpath.