JMX ComponentAvailable as of Camel 2.6 Standard JMX Consumer ConfigurationComponent allows consumers to subscribe to an mbean's Notifications. The component supports passing the Notification object directly through the Exchange or serializing it to XML according to the schema provided within this project. This is a consumer only component. Exceptions are thrown if you attempt to create a producer for it. Maven users will need to add the following dependency to their pom.xml for this component: <dependency> <groupId>org.apache.camel</groupId> <artifactId>camel-jmx</artifactId> <version>x.x.x</version> <!-- use the same version as your Camel core version --> </dependency> URI FormatThe component can connect to the local platform mbean server with the following URI:
jmx://platform?options
A remote mbean server url can be provided following the initial JMX scheme like so:
jmx:service:jmx:rmi:///jndi/rmi://localhost:1099/jmxrmi?options
You can append query options to the URI in the following format, ?options=value&option2=value&... URI Options
ObjectName ConstructionThe URI must always have the objectDomain property. In addition, the URI must contain either objectName or one or more properties that start with "key." Domain with Name propertyWhen the objectName property is provided, the following constructor is used to build the ObjectName? for the mbean: ObjectName(String domain, String key, String value) The key value in the above will be "name" and the value will be the value of the objectName property. Domain with HashtableObjectName(String domain, Hashtable<String,String> table) The Hashtable is constructed by extracting properties that start with "key." The properties will have the "key." prefixed stripped prior to building the Hashtable. This allows the URI to contain a variable number of properties to identify the mbean. Examplefrom("jmx:platform?objectDomain=jmxExample&key.name=simpleBean"). to("log:jmxEvent"); Monitor Type ConsumerAvailable as of Camel 2.8 CounterMonitor monitor = new CounterMonitor(); monitor.addObservedObject(makeObjectName("simpleBean")); monitor.setObservedAttribute("MonitorNumber"); monitor.setNotify(true); monitor.setInitThreshold(1); monitor.setGranularityPeriod(500); registerBean(monitor, makeObjectName("counter")); monitor.start(); The 2.8 version introduces a new type of consumer that automatically creates and registers a monitor bean for the specified objectName and attribute. Additional endpoint attributes allow the user to specify the attribute to monitor, type of monitor to create, and any other required properties. The code snippet above is condensed into a set of endpoint properties. The consumer uses these properties to create the CounterMonitor, register it, and then subscribe to its changes. All of the JMX monitor types are supported. Examplefrom("jmx:platform?objectDomain=myDomain&objectName=simpleBean&" + "monitorType=counter&observedAttribute=MonitorNumber&initThreshold=1&" + "granularityPeriod=500").to("mock:sink"); The example above will cause a new Monitor Bean to be created and depoyed to the local mbean server that monitors the "MonitorNumber" attribute on the "simpleBean." Additional types of monitor beans and options are detailed below. The newly deployed monitor bean is automatically undeployed when the consumer is stopped. URI Options for Monitor Type
The monitor style consumer is only supported for the local mbean server. JMX does not currently support remote deployment of mbeans without either having the classes already remotely deployed or an adapter library on both the client and server to facilitate a proxy deployment. See Also |