JMX Plugin
Dependency :
compile ":jmx:0.8"
Summary
Adds JMX support and provides the ability to expose services and other Spring beans as MBeans
Installation
grails install-plugin jmx
Description
JMX Plugin
This plugin adds JMX MBeanServer support through Spring.Plugin features:- Configures MBeanServer in Grails Application
- Registers services with JMX which are singletons that include the "expose" property, e.g. "static expose = ['jmx']"
- Provides default object naming {appname}:service=${serviceName},type=service
- Allows for object name override: static expose = ['jmx:service=Country,type=special']
- Allows for exclusion map: static jmxexpose = ['excludeMethods':'isTransactional,setTransactional,getTransactional,getJmxexpose,setJmxexpose,getExpose,setExpose']
- Checks to see if Hibernate is a plugin and if so it exposes the Hibernate Statistics MBean
- Exposes the Log4j MBean for runtime logging level configuration
- Exposes the Grails DataSource as an MBean
- Allows for any spring bean to be exposed through Config.groovy or with Spring @ManagedResource annotation
Setup
There is nothing to do after the install if you have no services to expose. Just run the application and use a JMX tool such as jconsole to administer.To be able to connect to the exposed services (which also includes the ones made available by the plugin by default) you have to set the system property com.sun.management.jmxremote before running your app.Exposing Services
By default, the plugin only supports exposing Services. This is accomplished by add 'jmx' to the static expose property as outlined below:class StateService { static expose = ['jmx']
…
}class CountryService { static expose = ['jmx:service=Country,type=special']
…
}Exposing Spring Beans
The plugin also supports exposing other Spring Beans - e.g. registered viaresources.groovy . This is accomplished by adding 'jmx' to the static expose property as outlined above and using the following code in @Config.groovy@grails {
jmx {
exportBeans = ['myBean']
}
}import org.springframework.jmx.export.annotation.ManagedAttribute import org.springframework.jmx.export.annotation.ManagedResource@ManagedResource class MyBean { private int count void setClickCount(int c) { count = c } @ManagedAttribute int getClickCount() { count } }