Camel JMXApache Camel has extensive support for JMX to allow you to monitor and control the Camel managed objects a JMX client.
Spring Dependencyspring-context.jar is needed on the classpath by Camel to be able to use JMX instrumentation. If this .jar is not on the classpath Camel will fallback to non JMX mode. This situation is logged at WARN level using logger name org.apache.camel.impl.DefaultCamelContext. Using JMX to manage Apache CamelBy default, JMX instrumentation agent is enabled in Camel which 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 supported types of management objects are endpoint The CamelNamingStrategy -Dorg.apache.camel.jmx.mbeanObjectDomainName=your.domain.name Or, by adding a jmxAgent element inside the camelContext element in Spring configuration: <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"> <jmxAgent id="agent" mbeanObjectDomainName="your.domain.name"/> ... </camelContext> Spring configuration always takes precedence over system properties when they both present. It is true for all of JMX related configurations. Disabling JMX instrumentation agent in CamelYou can disable JMX instrumentation agent by setting Java VM system property as follow. The property value is treated as boolean. -Dorg.apache.camel.jmx.disabled=True Or, by adding a jmxAgent element inside the camelContext element in Spring configuration: <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"> <jmxAgent id="agent" disabled="true"/> ... </camelContext> Locating a MBeanServer in the Java VMEach CamelContext can have an instance of InstrumentationAgent You can configure the matching default domain name via system property. -Dorg.apache.camel.jmx.mbeanServerDefaultDomain=<your.domain.name> Or, by adding a jmxAgent element inside the camelContext element in Spring configuration: <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"> <jmxAgent id="agent" mbeanServerDefaultDomain="your.domain.name"/> ... </camelContext> If no matching MBeanServer can be found, a new one is created and the new MBeanServer's default domain name is set according to the default and configuration as mentioned above. It is also possible to use the PlatformMBeanServer -Dorg.apache.camel.jmx.usePlatformMBeanServer=True Or, by adding a jmxAgent element inside the camelContext element in Spring configuration: <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"> <jmxAgent id="agent" usePlatformMBeanServer="true"/> ... </camelContext> Creating JMX RMI Connector ServerJMX connector server enables MBeans to be remotely managed by a JMX client such as JConsole. Camel JMX RMI connector server can be optionally turned on by setting system property and the MBeanServer used by Camel is attached to that connector server. -Dorg.apache.camel.jmx.createRmiConnector=True Or, by adding a jmxAgent element inside the camelContext element in Spring configuration: <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"> <jmxAgent id="agent" createConnector="true"/> ... </camelContext> JMX Service URLThe default JMX Service URL has the format: service:jmx:rmi:///jndi/rmi://localhost:<registryPort>/<serviceUrlPath>
registryPort is the RMI registry port and the default value is 1099. You can set the RMI registry port by system property. -Dorg.apache.camel.jmx.rmiConnector.registryPort=<port number> Or, by adding a jmxAgent element inside the camelContext element in Spring configuration: <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"> <jmxAgent id="agent" createConnector="true" registryPort="port number"/> ... </camelContext> serviceUrlPath is the path name in the URL and the default value is /jmxrmi/camel. You can set the service URL path by system property. -Dorg.apache.camel.jmx.serviceUrlPath=<path> Or, by adding a jmxAgent element inside the camelContext element in Spring configuration: <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"> <jmxAgent id="agent" createConnector="true" serviceUrlPath="path"/> ... </camelContext> By default, RMI server object listens on a dynamically generated port which can be a problem for connection established through a firewall. In such situation, RMI connection port can be explicitly set by the system property. -Dorg.apache.camel.jmx.rmiConnector.connectorPort=<port number> Or, by adding a jmxAgent element inside the camelContext element in Spring configuration: <camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"> <jmxAgent id="agent" createConnector="true" connectorPort="port number"/> ... </camelContext> When the connector port option is set, the JMX service URL will become: service:jmx:rmi://localhost:<connectorPort>/jndi/rmi://localhost:<registryPort>/<serviceUrlPath>
Using JConsole to monitor CamelThe CamelContext should appear in the list of local connections, if you are running JConsole on the same host as Camel. To connect to a remote Camel instance, or if the local process does not show up, use Remote Process option, and enter an URL. Here is an example localhost URL: service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi/camel
Using the Apache Camel which Jconsole The SystemProperties for Camel JMX support
JMX inside an Application ServerJBoss AS 4By default JBoss creates its own MBean server. To allow Camel to expose to the same server follow these steps: 1. Tell Camel to use the Platform MBean Server (This defaults to true in Camel 1.5) <camel:camelContext id="camelContext"> <camel:jmxAgent id="jmxAgent" mbeanObjectDomainName="org.yourname" usePlatformMBeanServer="true" /> </camel:camelContext> 2. Alter your JBoss instance to use the Platform MBean server. WebSphereAlter the mbeanServerDefaultDomain to be "WebSphere" <camel:jmxAgent id="agent" createConnector="true" mbeanObjectDomainName="org.yourname" mbeanServerDefaultDomain="WebSphere"/> Advanced JMX ConfigurationThe spring configuration file allows you to configure how Camel is exposed to JMX for management. In some cases, you could specify more information here, like the connector's port or the path name. Example:<camelContext id="camel" xmlns="http://activemq.apache.org/camel/schema/spring"> <jmxAgent id="agent" createConnector="true" registryPort="2000" mbeanServerDefaultDomain="org.apache.camel.test"/> <route> <from uri="seda:start"/> <to uri="mock:result"/> </route> </camelContext> If you wish to change the Java 5 JMX settings you can use various JMX system properties For example you can enable remote JMX connections to the Sun JMX connector, via setting the following environment variable (using set or export depending on your platform). These settings only configure the Sun JMX connector within Java 1.5+, not the JMX connector that Camel creates by default. SUNJMX=-Dcom.sun.management.jmxremote=true -Dcom.sun.management.jmxremote.port=1616 \ -Dcom.sun.management.jmxremote.authenticate=false -Dcom.sun.management.jmxremote.ssl=false (The SUNJMX environment variable is simple used by the startup script for Camel, as additional startup parameters for the JVM. If you start Camel directly, you'll have to pass these parameters yourself.) jmxAgent Properties Reference
|
