Posts Tagged ‘tips’

JMX tips

I’m hoping to continuously update this post as I come across important facts while developing JMX applications. So here we go…..

  1.  Do not pass complex structures to the JMX connection. JMX finds it difficult to render complex objects.
    e.g: Last week I was trying to pass a hash map which stored several other hash maps as its values, using MXBeans (The purpose was to add custom statistic support to UlraESB). 

    HashMap<String, HashMap<String, Integer>> statisticMap  = new HashMap<String, HashMap<String, Integer>>();
    

    The  statisticMap  was directly passed to the JMX connection. However the beans were created and visible through  the jconsole, but data wasn’t rendered. Then I tried out the following

    List<HashMap<String, Integer>> statisticList  = new ArrayList<HashMap<String, Integer>>();
    

    The list was directly passed to the connection and it worked like magic. Data were properly rendered. The only difference between these is that first design is “Maps in a Map” and the second is “Maps in a List”. I cannot explain why this happens… Please share your thoughts on this

  2. The objects which are passes to the JMX connection should be Serializable. If a static object is passed then the JMX connection would not be able to expose the data of that static object, since  static objects are not serializable. (Serialization can be only applied to objects and static variables does not belong to individual instances, they are class variables)
Advertisements