Apache Camel JMX link to introspect routes, end points, components, etc at runtime
This is an extension to the last two Apache Camel tutorials:
The JMX based MBeans provided by Apache Camel is useful for debugging and negative testings where you need to stop one or more routes. The JMX can be initiated via JConsole. We touched on using JConsole for
Step 1: Start the "StandAloneCamelWithSpring" that you created in the tutorial Apache Camel With Spring tutorial - Part 2. Once this route is running, you need to invoke the JConsole from a DOS command prompt.
Step 2: Select "local Process" and the "StandAloneCamelWithSpring" as highlighted above, and then click on "Connect".
Step 3: You need to select the "MBeans" tab to see all the MBeans, and then one of the MBeans is the Apache Camel under which you have components, routes, consumers, context, endpoint, etc available at runtime.
Step 4: The operations to stop and start routes are performed via the "operations" option as highlighted below.
JConsole can be used to connect to other remote JVM processes by providing hostname, port, and login credentials.
By default, JMX instrumentation agent is enabled in Camel. This means that Camel runtime creates and registers MBean management objects with a MBeanServer instance in the VM. This allows Camel users instantly obtain insights into how Camel routes perform down to the individual processor's level.
The domain name of the MBean object can be configured by Java VM system property:
Or, by adding a jmxAgent element inside the camelContext element in Spring configuration:
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> <jmxAgent id="agent" mbeanObjectDomainName="your.domain.name"/> ... </camelContext>
JMX can be disabled
<camelContext id="camel" xmlns="http://camel.apache.org/schema/spring"> <jmxAgent id="agent" disabled="true"/> ... </camelContext>
CamelContext camel = new DefaultCamelContext();