Using a JMX Console With ServiceMix
This document explains how to connect a JMX Console to ServiceMix. Two open-source JMX Consoles will be discussed:
The ServiceMix JBIContainer exposes internal services and Components through JMX. The JBIContainer can be passed a JMXBeanServer or be configured to create one, if one doesn't exist. (see Configuration). If the JBIContainer creates its own MBeanServer instance, it also creates an RMI JMXConnector - to allow remote connections. The Ant Tasks use this:
String jndiPath = <container name> + "JMX"; JMXServiceURL url = new JMXServiceURL ("service:jmx:rmi:///jndi/rmi://<namingHost>:<namingPort>/" + jndiPath) ; JMXConnector connector = JMXConnectorFactory.connect(url);
The following configuration variables will be needed in the next sections. Be aware, the values shown are the default settings for ServiceMix.
Default Settings
The default namingPort is 1099
The default container name is defaultJBI
The JMX Service URL is: service:jmx:rmi:///jndi/rmi://localhost:1099/defaultJBIJMX
Using JConsole
The Java-2 Platform, Standard Edition (J2SE) 5.0 release includes a JMX monitoring tool, JConsole. JConsole monitors applications running on the Java platform and provides information on their performance and resource consumption. Please see Sun's documentation for more information on using this tool. Note: this tool is available with the Java 5 release.
How to Use JConsole to Monitor ServiceMix
This section explains how to configure JConsole to monitor ServiceMix. The ServiceMix port number, the ServiceMix container id, and the JMX Service URL will be needed. This information was specified in the previous section in the Default Settings box.
- ServiceMix should be running first. Please see the #Getting Started Guide for instructions on running ServiceMix.
- Start JConsole from a command shell. The JConsole executable can be found in the
bin
directory of the J2SE installation directory.The JConsole window will appear.cd [J2SE_install_dir]\bin jconsole
- Click on the Advanced tab. The following URL must be entered in the "JMX URL" box: service:jmx:rmi:///jndi/rmi://hostname:port/app_to_monitor. Where the ((hostname}} is name of the host on which the application to be monitored is running, the
port
is the port number to connect to the application, and theapp_to_monitor
is the JMX enabled application to monitor. For example, if none of the defaults for ServiceMix have been modified and ServiceMix is running onlocalhost
, enter the following:service:jmx:rmi:///jndi/rmi://localhost:1099/defaultJBIJMX
.
JConsole Agent - Click the Connect box to connect to the ServiceMix container.
org.servicemix
will be visible in the console. Click onorg.servicemix
to see its MBeans.
JConsole Management & Monitoring
Testing JConsole with ServiceMix
- To see JConsole in action, start one of the ServiceMix examples running, for instance, the Basic Example:
wherecd [servicemix_install_dir]\examples\basic ..\..\bin\servicemix servicemix.xml
servicemix_install_dir
is the directory in which ServiceMix was installed. - Run JConsole (see previous section) and click on
org.servicemix
. - Click on
org.servicemix.jbi.framework.ComponentMBeanImpl
. The components of the Basic example will be shown. Clicking on any of them will show the monitoring information available.
JConsole Monitoring & Management Console
Using MC4J
MC4J is a JMX Console. It can connect to J2EE servers, MBeans, and applications and monitor them.
How to Use MC4Jto Monitor ServiceMix
This section explains how to configure MC4J to monitor ServiceMix. The ServiceMix port number, the ServiceMix container id, and the JMX Service URL will be needed. This information was specified in the previous section in the Default Settings box.
- ServiceMix should be running first. Please see the #Getting Started Guide for instructions on running ServiceMix.
- Click on the MC4J executable to start it. It can be found in the {{}} directory of the MC4J installation directory. The MC4Jwindow will appear.
- Click on the Advanced tab. The following URL must be entered in the "JMX URL" box: service:jmx:rmi:///jndi/rmi://hostname:port/app_to_monitor. Where the ((hostname}} is name of the host on which the application to be monitored is running, the
port
is the port number to connect to the application, and theapp_to_monitor
is the JMX enabled application to monitor. For example, if none of the defaults for ServiceMix have been modified and ServiceMix is running onlocalhost
, enter the following:service:jmx:rmi:///jndi/rmi://localhost:1099/defaultJBIJMX
.
JConsole Agent - Click the Connect box to connect to the ServiceMix container.
org.servicemix
will be visible in the console. Click onorg.servicemix
to see its MBeans.
JConsole Management & Monitoring
When you want to get at the ServiceMix MBeans using MC4J use JSR160 as your server connection type and the above default JMX Service URL as your server URL.
ServiceMix JMX Console
ServiceMix comes with a WAR which can be deployed, including ServiceMix inside any Servlet / J2EE application server in a standard deployment unit. The added benefit of the ServiceMix WAR is it includes a simple JMX operational console as well allowing your web browser to view JMX attributes and statistics.
To create the ServiceMix WAR from a fresh checkout of the code try this
cd servicemix/tooling/servicemix-web maven war
Then drop the WAR in any servlet engine.