2 Replies Latest reply on Nov 26, 2010 9:44 AM by 648215

    Monitoring jms distributed queue on WebLogic 8.1 via MBeans

    648215
      Good afternon,

      please do you have someone java code (only basic enough !) for jmx monitoring jms distributed queue on weblogic 8.1 (Monitor all Active JMS Destinations and there Consumers, Consumers High, Consumers Total and so on..). Think should be used JMSDestinationRuntimeMBean interface but have no idea how write the code.

      Thank you for any hint

      Lada Dvorak
        • 1. Re: Monitoring jms distributed queue on WebLogic 8.1 via MBeans
          815319
          This is a simple jmx sample code based on WLS 8.x

          import javax.naming.Context;
          import java.util.Set;
          import java.util.Iterator;

          import java.io.PrintWriter;
          import java.io.FileOutputStream;

          import weblogic.jndi.Environment;
          import weblogic.management.MBeanHome;
          import weblogic.management.WebLogicMBean;
          import weblogic.management.WebLogicObjectName;
          public class ListAllMBeans{   
               public static void main(String args[]) {       
                    String url = "t3://localhost:7001";
                    String username = "weblogic";
                    String password = "weblogic";
                    PrintWriter pWriter = null; // print without buffering

          try {            //Obtaining an MBeanHome Using JNDI           
                         Environment env = new Environment();
                         env.setProviderUrl(url);
                         env.setSecurityPrincipal(username);
                         env.setSecurityCredentials(password);
                         Context ctx = env.getInitialContext();
                         MBeanHome home = (MBeanHome)ctx.lookup(MBeanHome.ADMIN_JNDI_NAME);
          Set allMBeans = home.getAllMBeans();
                         System.out.println("Size: " + allMBeans.size());
                         for (Iterator itr = allMBeans.iterator(); itr.hasNext(); ) {              
                              WebLogicMBean mbean = (WebLogicMBean)itr.next();
                              WebLogicObjectName objectName = mbean.getObjectName();
                              pWriter = new PrintWriter(new FileOutputStream("JMXType.txt", true), true);
                              pWriter.println(objectName.getName() + " is a(n) " + mbean.getType());
                              //System.out.println(objectName.getName() + " is a(n) " + mbean.getType());
                         }
                         
                    }catch(Exception e){           
                         System.out.println(e);
                    }
               }
          }

          I hope this will be helpful to you.
          • 2. Re: Monitoring jms distributed queue on WebLogic 8.1 via MBeans
            648215
            Hello Kyoungmin,

            this is exactly what I needed !!

            thank you very much

            LD

            PS hope I'll be able render your help sometimes