简体   繁体   中英

JMX - monitor complex attribute of MBean

I have a simple third party object - a DTO with about 10+ public fields only (it get filled as an atomic operation). I would like to be able to monitor it in JConsole without writing a lot of boilerplate code.

I tried to:

  • Use MXBean - got an exception (NotCompliantMBeanException)
  • Convert the DTO to String using reflection-based utility library like apache.common.lang3.ReflectionToStringBuilder - works, but does not look good since JConsole does not support multi-line strings well, plus it is not efficient.

Any other suggestions?

It would be helpful if you posted you failing MXBean code. Typically, you would just need to define a DTOMXBean interface, make the DTO implement it and then register the DTO. (It sounds like a weird lifecycle for a DTO since they're usually fairly transient, but that's a topic for a different question).

Keep in mind that the MXBean attributes should not return values of types not defined in javax.management.openmbean.OpenType.ALLOWED_CLASSNAMES_LIST , otherwise you will get a NonCompliant exception. If you must expose types that cannot be represented as one of those types, you will need to define new composite types to expose them as.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM