Hi I think these JMX monitoring capabilities in the JDK only allows to monitor JMX attributes that are simple types like numbers, boolean etc.
So I am not sure if you can do this via https://github.com/apache/camel/blob/master/components/camel-jmx/src/main/java/org/apache/camel/component/jmx/JMXMonitorConsumer.java with the GaugeMonitor. On Mon, Jan 28, 2019 at 6:32 PM andrew cooke <[email protected]> wrote: > > > Hi, > > I have a specific error I need help with, but I may also be > approaching the problem incorrectly, so more general advice also > appreciated. Sorry for the length of this email - the questions are > at the end, after all the background data. > > (this is all with Camel 2.23.1, OpenJDK 1.8.0_111-b15, CentOS 7.2) > > I want to read the local JVM heap usage and write it to a file (the > final task is to write a variety of values for analysis later - the > client has some problem that occurs from time to time and they want > some way of looking back and trying to work out what happened). > > I have the following Spring XML config: > > <?xml version="1.0" encoding="UTF-8"?> > <beans ...> > > <camelContext xmlns="http://camel.apache.org/schema/spring"> > <route> > <from > uri="jmx:platform?objectDomain=java.lang&key.type=Memory&observedAttribute=HeapMemoryUsage&monitorType=gauge&thresholdHigh=0&thresholdLow=0&notifyHigh=True"/> > <log message="Got something"/> > <to uri="file:target/messages/dump"/> > </route> > </camelContext> > > </beans> > > The important part is the URI: > > jmx:platform?objectDomain=java.lang& > key.type=Memory& > observedAttribute=HeapMemoryUsage& > monitorType=gauge& > thresholdHigh=0 > thresholdLow=0& > notifyHigh=True > > This is giving the error (returned as an XML message): > > <?xml version="1.0" encoding="UTF-8" standalone="yes"?> > <MonitorNotification xmlns="urn:org.apache.camel.component:jmx"> > > <source>java.lang:name=camel-jmx-monitor-613d8391-408a-4677-9687-afcbf434d7bc</source> > <message>The observed attribute value does not implement the Comparable > interface.</message> > <sequence>0</sequence> > <timestamp>1548695162038</timestamp> > <dateTime>2019-01-28T14:06:02.038-03:00</dateTime> > <type>jmx.monitor.error.type</type> > <derivedGauge>null</derivedGauge> > <observedAttribute>HeapMemoryUsage</observedAttribute> > <observedObject>java.lang:type=Memory</observedObject> > <trigger>null</trigger> > </MonitorNotification> > > I suspect this is because the HeapMemoryUsage attribute is of type > javax.management.openmbean.CompositeData. > > So, finally, my questions are: > > * How do I access structured data like this? > > * If I just want the values every X seconds, can I just poll for > values? > > * Should I be doing something else? Like maybe configuring my own > notification? If so, is there some guide for dummies? And can > this be automated for monitoring many different valeus? > > Thanks, > Andrew -- Claus Ibsen ----------------- http://davsclaus.com @davsclaus Camel in Action 2: https://www.manning.com/ibsen2
