Custom Search SOABYTE here

Thursday, December 11, 2014

Oracle BPEL using JMX and MBeans

Oracle BPEL using JMX n MBeans

About JMX:

JMX (Java Management Extension) is part of J2SE 5.0 and meant to programmatically  manage and monitor application resources, Service Oriented Networks and Systems objects.   Refer the Wiki :

About MBeans:

MBeans, short  form of MangedBeans are used to represent the resources in jvm, java applications and application servers  through java objects. So, with the combination of JMX (Java programming APIs) and MBeans (java objects that are representing the resources such as Transaction monitors, JDBC Drivers and Printers and many more) we can collect/extract statistics related to performance, resource usages, and many more for the resources running in JVM.  Refer the Wiki:

This blog is meant to give some pointers/apis to fetch the details of resources (such as BPEL Domains, BPEL Servers, BPEL Composites, BPEL Composite configurations etc) hosted in Weblogic application server.  Have fun …


1)- Get BPEL Domains and Managed servers (weblogic) using JAVA 
2)- Get BPEL Composites hosted on Weblogic server
3)- Get BPEL Composite revisions
4)- Get all callable services (references) of a given BPEL Composite

1)- How to get BPEL Domains, managed servers, their restart dates and status :

public class PPKBPELExtraction {
    //Make sure to define below properties based on your BPEL Domain/Manged server setups.
    String host;
    String port;
    String userName;
    String pwd;
    String webserverHost;
    String defaultDomain;
    String bpel_listner_port;
    String bpel_listner_host;

            JMXServiceURL jmxServiceURL = null;
       Hashtable<String,String> jmxJNDIProperties = new Hashtable<String, String>();     
       JMXConnector jmxConnector = null;
       MBeanServerConnection mBeanServerConnection = null;    
       Hashtable<String, String> mBeanQueryStrings = new Hashtable<String, String>();
       String uriForDomainConfig = "/jndi/";
       JMXConnector jmxConnectorForDomainConfig = null;
       MBeanServerConnection mBeanServerConnectionForDomainConfig = null;
       Hashtable<String,String> jmxJNDIPropertiesForDomainConfig = new Hashtable<String, String>();       
       JMXServiceURL jmxServiceURLForDomainConfig = null;
       SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("dd-MM-yyyy HH:mm:ss");

public void getDomainDetails() {
       writeToLog(" getDomainDetails() => ");
              try {                                    
                     jmxServiceURLForDomainConfig = new JMXServiceURL("t3",,Integer.parseInt(this.port),uriForDomainConfig);
                     jmxConnectorForDomainConfig = JMXConnectorFactory.connect(jmxServiceURLForDomainConfigjmxJNDIPropertiesForDomainConfig);
                     mBeanServerConnectionForDomainConfig = jmxConnectorForDomainConfig.getMBeanServerConnection();
              } catch (Exception expGetDomainDetails) {
                     writeToLog("expGetDomainDetails : " + expGetDomainDetails.toString());
              String queryString = "com.bea:Name=DomainRuntimeService,";
       ObjectName domainObject = null;
       ObjectName domainObjectName = null;
       String domainName = null;
       Date activationDate = null;
              ObjectName[] serverObjects;
              int length = 0;
              String serverName;
              String serverState;
       try {
              ObjectName objectName = new ObjectName(queryString);
              Set<ObjectName> objectNameSet =mBeanServerConnectionForDomainConfig.queryNames(objectName, null);
              Iterator<ObjectName> objectNameSetIterator = objectNameSet.iterator();
              while (objectNameSetIterator.hasNext()){
                     domainObject =;
                     domainObjectName = (ObjectName) mBeanServerConnectionForDomainConfig.getAttribute(domainObject,"DomainRuntime");
                     domainName = (String) mBeanServerConnectionForDomainConfig.getAttribute(domainObjectName,"Name");
                     activationDate = (Date) mBeanServerConnectionForDomainConfig.getAttribute(domainObjectName, "ActivationTime");
                     serverObjects = (ObjectName[]) mBeanServerConnectionForDomainConfig.getAttribute(domainObject,"ServerRuntimes");
                     length = serverObjects.length;
                     Vector<Server> tmpServer = new Vector<Server>();
                     for (int i = 0; i < length; i++) {
                         serverName = (String) mBeanServerConnectionForDomainConfig.getAttribute(serverObjects[i], "Name");
                         serverState = (String) mBeanServerConnectionForDomainConfig.getAttribute(serverObjects[i],"State");
                         tmpServer.add(new Server(domainName,serverName,null,serverState));
            Domain(domainName, activationDate,this.type,tmpServer));
                     this.defaultDomain = domainName;
                     tmpServer = null;
                     domainObject = null;
              objectNameSetIterator = null;
              objectNameSet = null;
       } catch (Exception expDomain) {
     Domain(this.defaultDomain, (new Date()) ,"",null)); // Incase admin server is down.
              writeToLog("expDomain : " + expDomain.toString());
              writeToLog("Looks like Adminserver is having issues,  so defaulting Admin server activation date with sysdate");
            try {
                     if (jmxConnectorForDomainConfig != null)
                           jmxJNDIPropertiesForDomainConfig = null;
                           jmxConnectorForDomainConfig = null;
                           mBeanServerConnectionForDomainConfig = null;
              } catch (Exception expClose) {
                     writeToLog("expClose : " + expClose.toString());
              writeToLog(" <= getDomainDetails()");

2)- How to get bpel composites hosted in Weblogic managed server?

    public void fetchBPELComposite() {
        ObjectName compositeObjectName = null;
        String dn = null;
        Iterator<ObjectName> iterator = null;
        Set<ObjectName> queryObjectName = null;
        EndPoint endPoint = null;
        String compositeName = null
        String revision = null;
        String compositeName1 = null;
       try {
            ObjectName queryObject = new ObjectName("oracle.soa.config:j2eeType=SCAComposite,Application=soa-infra,*");
            queryObjectName = mBeanServerConnection.queryNames(queryObject, null);
            iterator = queryObjectName.iterator();

            while (iterator.hasNext()) {
              compositeObjectName =;
              dn = (String) mBeanServerConnection.getAttribute(compositeObjectName, "DN");
              compositeName = (String) mBeanServerConnection.getAttribute(compositeObjectName, "Name");
       } catch (Exception expGetBPELComposite) {
              writeToLog("getBPELComposite() " + expGetBPELComposite.toString());
       } finally {
            compositeObjectName = null;
            dn = null;
            iterator = null
            queryObjectName = null;

3)- How to get the default revision of a BPEL Composite

=> In the below api DN is the Compsoite DN name (which you can obtain from Enterprise manager).
       public boolean defaultRevision(String dn) {
              boolean returnValue= false;
              ObjectName queryObject = null;
              ObjectName soaInfra = null;
              Object[] vInputs = {dn};
              String[] vTypes = {String.class.getName()};
              try {
                     queryObject = new ObjectName("oracle.soa.config:name=soa-infra,j2eeType=CompositeLifecycleConfig,Application=soa-infra,*");
                     Set<ObjectName> objectNameSet = mBeanServerConnection.queryNames(queryObject, null);
                     Iterator<ObjectName> iterator = objectNameSet.iterator();
                     while (iterator.hasNext()) {
                           soaInfra =;
                           returnValue = (Boolean) mBeanServerConnection.invoke(soaInfra, "isDefaultCompositeRevision", vInputs, vTypes);
              }catch (Exception expIsDefaultRevision ) {
                     returnValue = false;
                     writeToLog("expIsDefaultRevision : "+ expIsDefaultRevision.toString());
              return returnValue;

4)- How to get the services (references) called from given BPEL Composite :

       public void bPELEndSCAReferences(EndPoint pEndPoint, String pCompositeName, String pRevision) {         
       StringBuffer querySB = newStringBuffer("oracle.soa.config:j2eeType=SCAComposite.SCAReference.SCABinding,wsconfigtype=ServiceRefMappingPortInfoConfig,revision=").append(pRevision).append(",Application=soa-infra,SCAComposite=\"");
       String query = querySB.toString().trim();
       ObjectName on = null;
       String referenceName = null;
       String referenceWSDL = null;
       Vector<EndPoint> ref = new Vector<EndPoint>();
       EndPoint reference = null;
       try {
              ObjectName qn = new ObjectName (query);
              Set<ObjectName> objectSet = mBeanServerConnection.queryNames(qn, null);
              Iterator<ObjectName> iterator = null;
              iterator = objectSet.iterator();
            while ((iterator != null) && (iterator.hasNext())) {
                 on =;
                 referenceName = (String) mBeanServerConnection.getAttribute(on, "PolicySubjectName");
                 referenceWSDL = (String) mBeanServerConnection.getAttribute(on, "Location");
                 reference = new EndPoint(this.defaultDomain, referenceName,null,true,"http","REFERENCE",referenceName,this.rand.nextLong());
                 reference.monitorURL = referenceWSDL;
                 //writeToLog("Domain " + this.defaultDomain +" Composite " + " Reference:" + referenceName +"; wsdl:"+ referenceWSDL);
       } catch (Exception exp) {
              writeToLog("PPK Exception in displayBPELEndSCAReferences()" + exp.toString());
              writeToLog("query string : " + query);
              writeToLog("composite : " + pCompositeName + pRevision);
       if ((pEndPoint.references != null) && (pEndPoint.references.size() > 0))
           pEndPoint.references = ref;


dhilBlog said...

Hi Amiya,

Can you share the import statements in this java file.
I'd like to know which jar file has the 'EndPoint' class file.


Unknown said...

Here you go :--

import java.util.ArrayList;
import java.util.HashMap;
import java.util.Hashtable;
import java.util.List;
import java.util.Map;
import java.util.Properties;
import java.util.Set;

Anonymous said...

Casinos in New Jersey, Nevada, Louisiana, Arkansas, and South Dakota now provide multi-state progressive jackpots, which now provide greater jackpot pools. A slot machine's theoretical payout proportion is ready at the manufacturing facility when the software is written. A theoretical maintain worksheet is a document provided by the manufacturer for each slot machine that signifies the theoretical proportion the machine ought to maintain based on the amount paid in. The worksheet additionally signifies the reel strip settings, variety of coins might be|that could be|which could be} played, the payout schedule, the variety of reels and other information descriptive of the particular kind of slot machine. Free spins are a typical type of bonus, where a series of spins are mechanically played at no charge at 카지노사이트 the player's current wager.

Post a Comment

Blogger Profile