Configuring JMX

Camel, by default, enables JMX for all routes and endpoints it creates by default. This recipe shows you how to configure Camel's interaction with JMX.

Getting ready

The Java code for this recipe is located in the org.camelcookbook.monitoring.jmx package. The Spring XML files are located under src/main/resources/META-INF/spring and prefixed with jmx.

How to do it...

In the XML DSL, create a jmxAgent element within the camelContext element, and configure the Camel JMX options:

<camelContext xmlns="http://camel.apache.org/schema/spring">
  <jmxAgent id="agent"
            connectorPort="1099"
            createConnector="false"
            usePlatformMBeanServer="true"
            serviceUrlPath="/jmxrmi/camel"
            loadStatisticsEnabled="true"
            statisticsLevel="All"/> <!-- route definitions ...

Get Apache Camel Developer's Cookbook now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.