Monday, April 21, 2014

Oracle SOA Suite – Getting the payload from the Composite instance - Part2

Oracle SOA Suite  – Getting the payload from the Composite instance - Part2

n the previous post Oracle SOA Suite– Getting the payload from the Composite instance - Part1 - Through Java API i explained how to get the Oracle SOA Suite composite instance payload through JAVA API. In the previous approach we are getting the full audit trail of the instance and the required input payloads are retrieved using DOM parser and XPath expressions.For the larger payloads this approach fails to retrieve the payload.

In this post i am explaining the approach to get the Binary payload data from the database by executing the SQL statement and parsing the same to string message.

In Oracle SOA 11g the input payload related to the composite instances(input  to the composite and all the input payload send to the references) are stored in INSTANCE_PAYLOAD(the actual XML payload is kept in XML_DOCUMENT table) table.

By querying the INSTANCE_PAYLOAD, XML_DOCUMENT and COMPOSITE_INSTANCE we can retrieve the binary input payload for a particular composite instance.After receiving the XML payload as binary we can use the java code to transform the same to string format.

import java.io.StringWriter;
import java.sql.*;
import java.util.Hashtable;
import javax.naming.*;
import javax.xml.transform.*;
import javax.xml.transform.dom.DOMSource;
import javax.xml.transform.stream.StreamResult;
import oracle.xml.binxml.*;
import oracle.xml.parser.v2.*;
import oracle.xml.scalable.InfosetReader;

public class GetPayload {
    public static Connection getConnection() throws Exception {
        Context ctx = null;
        Hashtable ht = new Hashtable();
        ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
        ht.put(Context.PROVIDER_URL, "t3://localhost:8000");
        ctx = new InitialContext(ht);
        javax.sql.DataSource ds =(javax.sql.DataSource)ctx.lookup("jdbc/SOADataSource");
        return ds.getConnection();
    }

    public static String getPayload() {
        Statement stmt = null;
        Connection connection = null;
        ResultSet rs = null;
        String query =
            "select xmldoc.document DOC " + "from xml_document xmldoc,instance_payload inspay,composite_instance cmpins " +
            "where xmldoc.document_id = inspay.payload_key " +
            "and inspay.instance_id = cmpins.id " +
            "and inspay.instance_type='composite' " +
            "and xmldoc.DOCUMENT_TYPE = 2 " +
            "and inspay.instance_id = 7648669";      
   
        String payload = "";
        XMLDocument doc = null;
        try {
            connection = getConnection();
            stmt = connection.createStatement();
            rs = stmt.executeQuery(query);
            XMLDOMImplementation xmldomimpl = new XMLDOMImplementation();
            while (rs.next()) {                    
                BinXMLProcessor xmlprocessor =BinXMLProcessorFactory.createProcessor();
                BinXMLStream xmlstream =xmlprocessor.createBinXMLStream(rs.getBlob("DOC"));
                BinXMLDecoder xmldecoder = xmlstream.getDecoder();
                InfosetReader xmlreader = xmldecoder.getReader();
                doc = (XMLDocument)xmldomimpl.createDocument(xmlreader);
                TransformerFactory tf = TransformerFactory.newInstance();
                Transformer transformer;
                transformer = tf.newTransformer();
                transformer.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION,"yes");
                StringWriter writer = new StringWriter();
                transformer.transform(new DOMSource(doc),new StreamResult(writer));
                payload =writer.getBuffer().toString().replaceAll("<", "&lt;").replaceAll(">","&gt;");      
           }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (rs != null)
                    rs.close();
                if (stmt != null)
                    stmt.close();
                if (connection != null)
                    connection.close();
            } catch (Exception e) {

            }
        }
        return payload;

    }
}

The same query will not work in Oracle SOA Suite 12c to retrieve the payload as some of the tables are decommissioned in Oracle SOA Suite 12c e.g. INSTANCE_PAYLOAD and COMPOSITE_INSTANCE

If the process is asynchronous then the input payload is stored into the XML_DOCUMENT, the below query can be used to retrieve the BLOB data from XML_DOCUMENT table(modify the query in java code to parse the BLOB data)

SELECT XMLDOC.DOCUMENT DOC FROM XML_DOCUMENT XMLDOC , DLV_MESSAGE DLV,DOCUMENT_DLV_MSG_REF DLVREF WHERE DLVREF.MESSAGE_GUID=DLV.MESSAGE_GUID AND MLDOC.DOCUMENT_ID=DLVREF.DOCUMENT_ID AND DLV.CIKEY=10048;

If the payload size of the synchronous process is more than the threshold the input payload is stored in AUDIT_DETAILS table as BLOB data, the following query can be used to retrieve the blob data

SELECT BIN FROM AUDIT_DETAILS WHERE CIKEY=10102

Refer the following post with more details on retrieving the data from AUDIT_DETAILS -https://www.albinsblog.com/2014/04/getting-xml-form-auditdetails-table.html

Use the xmlparserv2.jar file from the following location $MIDDLE_HOME/oracle_common/modules/oracle.xdk_11.1.0(the xmlparserv2.jar downloaded from Google may not have some of the class files included)

Enable the ClusterConstraints in weblogic server - Oracle SOA Suite 11g

Enable the ClusterConstraints in weblogic server - Oracle SOA Suite 11g :

It is possible to change WebLogic Server’s default deployment behavior for clusters by setting the ClusterConstraintsEnabled option when starting the WebLogic Server domain. The ClusterConstraintsEnabled option enforces strict deployment for all servers configured in a cluster. A deployment to a cluster succeeds only if all members of the cluster are reachable and all can deploy the specified files.

This post will explain the different approaches to change Cluster Constraint.

Through EM console:

Login to EM console 
Right click on soa-infra-->Admiistration-->System MBean browser
Enter com.bea:Name=SOACoreDomain,Type=Domain in the MBean browser filter and click ok


Change the ClusterConstraintEnabled attribute accordingly and click on Apply button


Getting the XML form AUDIT_DETAILS table through Java- Oracle SOA Suite

Getting the XML form AUDIT_DETAILS table through Java- Oracle SOA Suite

In Oracle SOA Suite 11g or  Oracle SOA Suite 12c when the Audit trail sizeof the BPEL instance is more then the configured Threshold value then the audit trails are stored in AUDIT_DETAILS table.The single instance will have multiple audit details.


The XML documents in the AUDIT_DETAILS are compressed, this post will explain how to retrieve the XML documents from AUDIT_DETAILS through java.

package getpayloadweb;
import java.sql.Connection;
import java.sql.ResultSet;
import java.sql.Statement;

import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;

public class GetPayload {
    public GetPayload() {
        super();
    }

    public static Connection getConnection() throws Exception {
        Context ctx = null;
        Hashtable ht = new Hashtable();
        ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
        ht.put(Context.PROVIDER_URL, "t3://localhost:8000");
        ctx = new InitialContext(ht);
        javax.sql.DataSource ds =(javax.sql.DataSource)ctx.lookup("jdbc/SOADataSource");
        return ds.getConnection();
    }

    public static String getPayload() {
        Statement stmt = null;
        Connection connection = null;
        ResultSet rs = null;
     
     String query="select  UTL_COMPRESS.LZ_UNCOMPRESS(b.bin) DOC from audit_details b where cikey='5148077' and rownum<2";
     
        String payload = "";
        try {
            connection = getConnection();
            stmt = connection.createStatement();
            rs = stmt.executeQuery(query);
           while (rs.next()) {
                 
                 Blob blob=rs.getBlob("DOC");
                  byte[] sdata = blob.getBytes(1, (int) blob.length());;
                  payload = new String(sdata);
         
            }
        } catch (Exception e) {
            e.printStackTrace();
        } finally {
            try {
                if (rs != null)
                    rs.close();
                if (stmt != null)
                    stmt.close();
                if (connection != null)
                    connection.close();
            } catch (Exception e) {

            }
        }
        return payload;

    }
}

Friday, April 18, 2014

Increasing the performance of EM console in Oracle SOA Suite 11g - Part2

Increasing the performance of EM console in Oracle SOA Suite 11g - Part2

The post https://www.albinsblog.com/2012/04/increasing-performance-of-em-console-in.html#.U1D_JvmukdQ explains some of the steps to improve the EM console performance in Oracle SOA Suite 11g  .

Additional steps to improve the EM console performance.

The EM conolse uses the Dynamic  Monitoring System(DMS) module to collect the metrics from all the DMS enabled targets.
If the frequency of the DMS collection is to fast then the EM console will become slow.

To increase the frequency of the DMS collection, increase the value of intervalSeconds in the $MIDDLEWARE_HOME/oracle_common/modules/oracle.dms_11.1.1/server_config.xml file to higher value.

 <collectorConfiguration>
    <prefetch intervalSeconds="15" removeCycle="2" isDefault="true"/>
    <prefetch intervalSeconds="300" removeCycle="3"/>
    <discover intervalSeconds="180"/>
  </collectorConfiguration>

to

 <collectorConfiguration>
    <prefetch intervalSeconds="15" removeCycle="2" isDefault="true"/>
    <prefetch intervalSeconds="300" removeCycle="3"/>
    <discover intervalSeconds="600"/>
  </collectorConfiguration>


Target the DMS application only to the SOA servers.


DMS Spy Servlet to monitor/retrieve the metrics - Oracle SOA Suite platform

DMS Spy Servlet to monitor/retrieve the metrics - Oracle SOA Suite platform

This post will explain how to monitor Oracle SOA Suite application through DMS Spy Servlet

The DMS Spy servlet provides access to DMS metric data from a web browser. Data that is created and updated by DMS-enabled applications and components is accessible through the DMS Spy Servlet.

The DMS Spy Servlet is part of the DMS web application. The DMS web application's web archive file is dms.war, and can be found in the same directory as dms.jar: <ORACLE_HOME>/modules/oracle.dms_11.1.1/dms.war.

The DMS web application is deployed by default as part of a JRF-enabled server instance. The URL is: http://host:port/dms/Spy.

Only users who have Administrator role access can view this URL as access is controlled by standard Java EE elements in web.xml.

This can be used to monitor Oracle SOA Composites, SOA Components, JVM, Datasources and MDS etc..

How to get the metrics through wget command:

The required metrics can be retrieved through wget command and exported to a XML format.

Login to server to execute the Spy servlet

wget --save-cookies cookies.txt --keep-session-cookies --post-data "j_username=weblogic&j_password=password&j_character_encoding=UTF-8" --delete-after http://localhost:7201/dms/j_security_check

Invoke the Spy servlet to fetch the required metrics

wget64 --load-cookies cookies.txt "http://localhost:7201/dms/Spy?format=xml&cache=false&prefetch=false&table=JVM&orderby=Name" -O server_JVM_metrics.xml

This will export the JVM metrics in XML format to server_JVM_metrics.xml

<?xml version='1.0' encoding='UTF-8'?>
<tbml xmlns="http://www.oracle.com/AS/collector" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" version='11.0' id='7201' host='192.x.x.x' name='AdminServer' timestamp='1514398197366'>
<table name='JVM' keys='Host Name Parent Process' componentId='AdminServer'>
<row>
<column name='Name'><![CDATA[JVM]]></column>
<column name='Parent'><![CDATA[/]]></column>
<column name='Host'><![CDATA[192.x.x.x]]></column>
<column name='Process'><![CDATA[AdminServer:7201]]></column>
<column name='ServerName'><![CDATA[AdminServer]]></column>
<column name='upTime.value' type='LONG'>2400665</column>
<column name='totalMemory.value' type='INTEGER'>1974272</column>
<column name='totalMemory.minValue' type='DOUBLE'>1601536.0</column>
<column name='totalMemory.maxValue' type='DOUBLE'>1974272.0</column>
<column name='startTime.value' type='LONG'>1514395796693</column>
<column name='freeMemory.value' type='INTEGER'>806464</column>
<column name='freeMemory.minValue' type='DOUBLE'>700532.0</column>
<column name='freeMemory.maxValue' type='DOUBLE'>1245019.0</column>
<column name='activeThreads.value' type='INTEGER'>258</column>
<column name='activeThreads.minValue' type='DOUBLE'>43.0</column>
<column name='activeThreads.maxValue' type='DOUBLE'>258.0</column>
<column name='activeThreadGroups.value' type='INTEGER'>102</column>
<column name='activeThreadGroups.minValue' type='DOUBLE'>7.0</column>
<column name='activeThreadGroups.maxValue' type='DOUBLE'>102.0</column>
</row>
</table>
</tbml>