Over a million developers have joined DZone.
{{announcement.body}}
{{announcement.title}}

Defining Custom JMX Attributes in Apache Camel 2.16

DZone's Guide to

Defining Custom JMX Attributes in Apache Camel 2.16

It used to not be possible to add custom JMX operations, but see how Clause Ibsen is working to commit custom JMX components.

· Integration Zone ·
Free Resource

Download Microservices for Java Developers: A hands-on introduction to frameworks and containers. Brought to you in partnership with Red Hat.

Apache Camel 2.16 - Components with custom JMX is now an addon on top of the standard set of JMX.

In the upcoming Apache Camel 2.16, I took a second attempt (I am currently writing about JMX for the Camel in Action 2nd edition book) of making it much easier to define custom JMX attributes and operations on your components, and have that added it to the standard set of JMX that Camel provides by default.

Beforehand, it was not possible to add custom JMX operations to the standard set. To make this possible, you would need to re-expose the standard set of JMX in your custom component.

But I am happy to have found a solution that is being committed shortly to Apache Camel 2.16. 

This simple custom component (from the Camel in Action book) exposes a single JMX attribute named verbose on the custom component called ERP.

The custom component exposes a JMX attribute named Verbose. Using this component at runtime in Apache Camel 2.15.2 only shows the Verbose attribute:

But the same code running on Apache Camel 2.16.0 now has all the default JMX attributes and operations as well:

This works also for any custom bean you may use in your routes. For example, if you call a POJO using bean in the route DSL, then the custom POJO will be listed in JMX under processors. All you have to do in your POJO is annotate it with the Camel @ManagedResources and then @ManagedAttribute for attributes and @ManagedOperation for operations.

All the existing Camel components we have (150+) could also benefit from this. They would be able to expose more custom information in JMX for their endpoints, consumer, producers, etc. We have held back a bit in the past to do this due to this problem. This task has been logged as CAMEL-9074.

Download Building Reactive Microservices in Java: Asynchronous and Event-Based Application Design. Brought to you in partnership with Red Hat

Topics:
apache camel ,jmx ,fuse ,camel

Published at DZone with permission of

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}