11 Replies Latest reply on Feb 1, 2008 9:21 PM by 666705

    Getting runtime "state" of a messagingbridge using MBeans in weblogic10..

    666705
      Hi,
                
                We are trying to get the runtime state of a configured messaging bridge in WebLogic10 using MBeans. From the docs it looks like we need to use the MessagingBridgeRuntimeMBean which has got the "state" attribute . But for some reason the access path for this MBean is not documented and hence we are not able to figure out the ObjectName to access this MBean via the latest standard jmx model (drilling down using ObjectNames).. On the other hand we are able to get the value of the "started" attribute which is found in the MessagingBridgeMBean but this is not helpful as it just tells whether the Bridge has started or not. Below is the code to get to this attribute :
                *************************************************************
                //connect to the MBeanServer first
                String son = "com.bea:Name=DomainRuntimeService,Type=weblogic.management.mbeanservers.domainruntime.DomainRuntimeServiceMBean"
                ObjectName service = null;
                try {
                service = new ObjectName(son);
                }catch (MalformedObjectNameException moe) {
                moe.printStackTrace();
                }
                //get the ObjectName for the DomainMBean -
                ObjectName dn = (ObjectName)connection.getAttribute (service,"DomainConfiguration");
                System.out.println("Domain Configuration : " +dn.getKeyProperty("Name"));
                //now get the ObjectName for all the "configured" messaging bridges
                ObjectName[] mbs = (ObjectName[])connection.getAttribute(dn,"MessagingBridges");
                for(int i=0;i<mbs.length;i++){
                System.out.println(mbs.toString());
                String mbName = mbs[i].getKeyProperty("Name");
                String status = connection.getAttribute(mbs[i],"Started").toString();
                System.out.println("The Messaging Bridge " mbName " has status "+status);
                }
                *******************************************************************
                
                How can we get the runtime "state" of the messaging bridge using the MessagingBridgeRuntimeMBean in Weblogic10 ?
                
                In betw, we also used the WLST tool but did not see the MessagingBridgeRuntime in the console..
                
                - thanx
        • 1. Re: Getting runtime "state" of a messagingbridge using MBeans in weblogic10..
          666705
          Please check out the documentation at
                    http://edocs.bea.com/wls/docs100/j2eemanage/understanding.html
                    
                    The attributes of MessagingBridgeRuntimeMBean can be found at
                    http://e-docs.bea.com/wls/docs100/javadocs_mhome/weblogic/management/runtime/MessagingBridgeRuntimeMBean.html
                    
                    Thanks,
                    Dongbo
          • 2. Re: Getting runtime "state" of a messagingbridge using MBeans in weblogic10..
            666705
            Just to add, there isn't really much to monitor on a messaging bridge other than its state. If the state is not started, the description attribute may tell you why. May I ask what you are looking for from the runtime bean about a messaging bridge?
                      
                      Thanks,
                      Dongbo, BEA
            • 3. Re: Getting runtime "state" of a messagingbridge using MBeans in weblogic10..
              666705
              Thanx Dongbo very much for this,
                        
                        I guess what you are implying here is :
                        1) Use the ManagementHome interface and then
                        get the ObjectNames of all the running MBeans in the domain/server.
                        2) This should also contain the ObjectName of the running MessagingBridgeRuntimeMBean.
                        3) Use the above ObjectName in the MBeanServerConnection class method getAttribute(ObjectName on, String attribute) .. Here the attribute would be "state".
                        
                        I just ran this program and ran into marshalling exception. I am using jdk1.5 with java options -Djmx.serial.form=1.0 -Dcom.sun.xml.na
                        mespace.QName.useCompatibleSerialVersionUID=1.0.
                        
                        I also have the wljmxclient.jar,weblogic.jar and api.jar in my classpath.
                        
                        Below is the stack trace :
                        java.rmi.MarshalException: CORBA MARSHAL 0 No; nested exception is:
                        org.omg.CORBA.MARSHAL: vmcid: 0x0 minor code: 0 completed: No
                        at com.sun.corba.se.impl.javax.rmi.CORBA.Util.mapSystemException(Util.ja
                        va:197)
                        at javax.rmi.CORBA.Util.mapSystemException(Util.java:67)
                        at org.omg.stub.javax.management.j2ee._Management_Stub.queryNames(Unknow
                        n Source)
                        at com.db.eps.tracer.common.utils.bridgemonitoring.BridgeMonitor2.getAll
                        JMONames(Unknown Source)
                        at com.db.eps.tracer.common.utils.bridgemonitoring.BridgeMonitor2.main(U
                        nknown Source)
                        Caused by: org.omg.CORBA.MARSHAL: vmcid: 0x0 minor code: 0 completed: No
                        at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
                        at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstruct
                        orAccessorImpl.java:39)
                        at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingC
                        onstructorAccessorImpl.java:27)
                        at java.lang.reflect.Constructor.newInstance(Constructor.java:494)
                        at java.lang.Class.newInstance0(Class.java:350)
                        at java.lang.Class.newInstance(Class.java:303)
                        at com.sun.corba.se.impl.protocol.giopmsgheaders.MessageBase.getSystemEx
                        ception(MessageBase.java:897)
                        
                        Am i missing some other jars here..
                        
                        - thanx
              • 4. Re: Getting runtime "state" of a messagingbridge using MBeans in
                666705
                The thin jars tend to be less functional, or you simply might be missin a jar as you already suspect.
                          
                          I recommend starting with the single "full" jar and using the "t3" protocol - the full jar is larger but has the most features and tends to yield the best performance.
                          
                          For more information, see:
                          
                          http://edocs.bea.com/wls/docs100/client/basics.html
                          
                          Tom
                • 5. Re: Getting runtime "state" of a messagingbridge using MBeans in weblogic10..
                  666705
                  Donbo,
                            
                            We are looking for the "runtime" state of the messaging bridge. The MessagingBridgeMBean (a configuration type Bean) has a "started" attribute which return true if started and false if stopped. This we are able to access.
                            
                            If we go thru the weblogic 10 admin console and click on the configured Bridge there is a "started" attribute. Click on
                            more info against the started attribute and this is what the doc says :
                            
                            **********************************************************************
                            Started Specifies the initial operating state of a targetted messaging bridge instance.
                            If enabled, the messaging bridge instance forwards messages (running).
                            If not enabled, the messaging bridge instance does not forward messages (temporarily stopped).
                            After a messaging bridge has started forwarding messages (running), use Started to temporarily suspend an active messaging bridge instance or restart an stopped messaging bridge instance
                            
                            This value does not indicate the run-time state of a messaging bridge instance.
                            
                            So our hunch is there should be a runtime state of the messaging bridge that we could use..
                            
                            *****************************************************************
                            
                            We then found that the runtime state of a bridge in weblogic 10 can be figured out using MessagingBridgeRuntimeMBean attribute "state" .
                            
                            Here is the link to the doc where we refered to :
                            http://edocs.bea.com/wls/docs92/wlsmbeanref/core/index.html
                            
                            Here under Runtime MBean section there is a MessagingBridgeRuntimeMBean . For some reason the "access points" for this MBean is not defined (for all other MBeans this has been defined)..
                            
                            Here is where we are stuck at...
                            
                            
                            - regards
                  • 6. Re: Getting runtime "state" of a messagingbridge using MBeans in
                    666705
                    Thanx Tom,
                              
                              I built the wlfullclient.jar and started my client with it ...But now I am ending with this exception..
                              
                              Exception in thread "main" java.lang.SecurityException: Invalid signature file d
                              igest for Manifest main attributes
                              at sun.security.util.SignatureFileVerifier.processImpl(SignatureFileVeri
                              fier.java:221)
                              at sun.security.util.SignatureFileVerifier.process(SignatureFileVerifier
                              .java:176)
                              at java.util.jar.JarVerifier.processEntry(JarVerifier.java:276)
                              at java.util.jar.JarVerifier.update(JarVerifier.java:188)
                              at java.util.jar.JarFile.initializeVerifier(JarFile.java:325)
                              at java.util.jar.JarFile.getInputStream(JarFile.java:390)
                              at sun.misc.URLClassPath$JarLoader$1.getInputStream(URLClassPath.java:62
                              0)
                              at sun.misc.Resource.cachedInputStream(Resource.java:58)
                              at sun.misc.Resource.getByteBuffer(Resource.java:113)
                              at java.net.URLClassLoader.defineClass(URLClassLoader.java:249)
                              at java.net.URLClassLoader.access$100(URLClassLoader.java:56)
                              at java.net.URLClassLoader$1.run(URLClassLoader.java:195)
                              at java.security.AccessController.doPrivileged(Native Method)
                              at java.net.URLClassLoader.findClass(URLClassLoader.java:188)
                              at java.lang.ClassLoader.loadClass(ClassLoader.java:306)
                              at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:268)
                              at java.lang.ClassLoader.loadClass(ClassLoader.java:251)
                              at java.lang.ClassLoader.loadClassInternal(ClassLoader.java:319)
                              
                              I guess it is coming when it is trying to load classes from this newly created jar file..
                              
                              - regards
                    • 7. Re: Getting runtime "state" of a messagingbridge using MBeans in
                      666705
                      My only guess is that you have a classpath problem: Make sure you only have the full jar in your classpath (don't mix thin and thick jars).
                      • 8. Re: Getting runtime "state" of a messagingbridge using MBeans in weblogic10..
                        666705
                        You are right. The “started” attribute of the configuration mbean MessagingBridgeMBean only indicates the initial state of a messaging bridge. The runtime state is in MessagingBridgeRuntimeMBean.
                                  
                                  I suspect that some links in the runtime mbean hierarchy are missing for MessagingBridgeRuntimeMBean, and as a result, you could not access the runtime mbean following the runtime mbean tree.
                                  
                                  I recall that I was able to access MessagingBridgeRuntimeMBean in previous releases using the WebLogic Admin command line tool. It should work the same in 10.0.
                                  The following command lists all MessagingBridgeRuntimeMBean instances with all of the attributes.
                                  java weblogic.Admin -url your-server-url -username server-username -password server-password GET -pretty -type MessagingBridgeRuntime
                                  
                                  If you have the runtime mbean name of a particular bridge instance (or once you obtain the name from the previous command), you should be able to view only that instance using the following command.
                                  java weblogic.Admin -url your-server-url -username server-username -password server-password GET -pretty -type MessagingBridgeRuntime -mbean messaging-bridge-runtime-mbean-name
                                  
                                  Regards,
                                  Dongbo, BEA
                        • 9. Re: Getting runtime "state" of a messagingbridge using MBeans in weblogic10..
                          666705
                          Thanx a bunch Dongbo,
                                    
                                    using the below the 2 commands i am getting the MBean Object Name . Here is the output ..
                                    MBeanName: "messagingmydomain:ServerRuntime=messagingmybridgeserver,Name=MyBridge,Type=MessagingBridgeRuntime,Location=messagingmybridgeserver"
                                    CachingDisabled: true
                                    Description: WARN: failed to connect to the source.
                                    Name: MyBridge
                                    Parent: messagingmybridgeserver
                                    Registered: true
                                    State: Inactive
                                    Type: MessagingBridgeRuntime
                                    
                                    
                                    Now having got the MBean name ie the ObjectName I replaced it in my java code like this (after connection to a Runtime MBean Server where the Bridge is deployed to) :
                                    
                                    ************************************************
                                    private MBeanServerConnection connection = getRuntimeMBeanServerConnection();
                                    String son = "messagingmydomain:ServerRuntime=messagingmybridgeserver,Name=MyBridge,Type=MessagingBridgeRuntime,Location=messagingmybridgeserver";
                                    ObjectName service = null;
                                    try {
                                    service = new ObjectName(son);
                                    }catch (MalformedObjectNameException moe) {
                                    moe.printStackTrace();
                                    }
                                    String status = connection.getAttribute(service,"State").toString();
                                    System.out.println("The Messaging Bridge has status "+status);
                                    **********************************************
                                    
                                    But then I get an InstanceNotFoundException(I am connecting to the right server using t3)...
                                    But the command you suggested, finds the Bridge and returns the status ie Inactive.. Am i doing something wrong in the code above??
                                    
                                    In betw, as I guess you are in BEA if the links to get to the MessagingBridgeRuntimeMBean from the runtime MBean hierarchy could be fixed ,it would be great !!
                                    
                                    Thanx a lot again..
                          • 10. Re: Getting runtime "state" of a messagingbridge using MBeans in weblogic10..
                            666705
                            The key is to use the right ObjectName with the right runtime mbean server.
                                      As you may have known, there is a compatibility mbean server, uses old WebLogic proprietary APIs. The APIs were deprecated two releases ago after JMX defined the MBeanServerConnection standard APIs. The Admin tool uses THAT mbean server. The compatibility mbean server shows a different ObjectName from the current JMX MBeanServerConnection based mbean server. As a result, you cannot use an ObjectName obtained from the Admin tool in your JMX client that uses the MBeanServerConnection API. I don't think you should worry about using the compatibility mbean server. The following code snippet shows you how to get all mbeans from the runtime mbean server using JMX APIs. You can lookup the runtime mbean server and connect to it as you have been doing.
                                      
                                      QueryExp exp = Query.match(Query.attr("Name"),
                                      Query.value("*"));
                                      Set objNames = connection.queryNames(new ObjectName(""), exp);
                                      System.out.println("Found " + objNames.size() + " mbeans in this tree ...");
                                      Iterator iter = objNames.iterator();
                                      while (iter.hasNext()) {
                                      ObjectName on = (ObjectName) iter.next();
                                      if (on.toString().indexOf("MessagingBridgeRuntime") != -1) {
                                      String state =
                                      (String) connection.getAttribute(on,"State");
                                      System.out.println("mbean = " + on + " state = " + state);
                                      }
                                      }
                                      
                                      This should give you some ideas on how to find a MessagingBridgeRuntimeMBean instance using JMX. You’ll notice that the ObjectName you obtained here is different from what you got using Admin tool. With an ObjectName you got here, you can do all JMX operations as you expected.
                                      
                                      I know the whole thing is a little confusing, and I hope everything is fine after you get the right ObjectNames.
                                      
                                      Please feel free to contact BEA support if you think the possible missing link issue is really important to you.
                                      
                                      Thanks,
                                      Dongbo, BEA
                            • 11. Re: Getting runtime "state" of a messagingbridge using MBeans in weblogic10..
                              666705
                              Thanx Dongbo for nailing this down ...