Friday, October 28, 2011

Oracle SOA Suite – Disabling the Auto recovery of Faulted Instances,invoke and callback messages.


Oracle SOA Suite – Disabling the Auto recovery of Faulted Instances,invoke and callback messages:

Auto recovery is the functionality to recover the faulted instances and Invoke and Callback messages in Oracle SOA 11g or Oracle SOA 12c
Sometimes we need to disable this feature to avoid unnecessary table space growth and recovering the instance that fail even after the recovery.

Disabling recovery attempts for faulted instances.

1. Log in to Oracle Enterprise Manager Fusion Middleware Control.
2. Right-click soa-infra.
3. Select SOA Administration > BPEL Properties.
4. Click More BPEL Configuration Properties.
5. In the Name column, click RecoveryConfig.
6. Expand RecurringScheduleConfig.
7. Set the following properties to values and click Apply.
maxMessageRaiseSize =0
8. Expand StartupScheduleConfig, respectively.
9. Set the following properties to values and click Apply.
maxMessageRaiseSize=0




Oracle SOA Suite – Creating SOA partition through WLST

Oracle SOA Suite – Creating SOA partition through WLST:


In Oracle SOA Suite 10g we had the functionality to create different domains in the BPEL Console to group our applications.
The same functionality can be achieved in Oracle SOA Suite 11g or Oracle SOA Suite 12c by creating different partitions.
The SOA Composites can be grouped into different partitions as shown below.





WLST Script:

The below code snippet will enable us to create the required partitions in SOA server.
The required values need to be changed accordingly.

from oracle.fabric.blocks.folder import Folder
from oracle.fabric.management.folder import FolderManager
from javax.management import MBeanException
from java.lang.reflect import InvocationTargetException
# This command creates the partition
# @partitionName The name of the partition
def sca_createPartition(partitionName):
foldermbean = sca_getFolderMBean();
print 'partitionName =', partitionName
params = jarray.array([partitionName],java.lang.Object)
signature = jarray.array(['java.lang.String'],java.lang.String)
try:
# print 'Calling folder mbean to create partition...'
mbs.invoke(foldermbean, "create", params, signature)
# print 'Partition was successfully created.'
print WLSTMessageBundle.getStringNoArg(WLSTMessageID.FOLDER_CREATE_SUCCESS)
except MBeanException, mbeanEx:
if mbeanEx.getCause() != None and isinstance(mbeanEx.getCause(), InvocationTargetException) and mbeanEx.getCause().getCause() != None:
# print mbeanEx.getCause().getCause()
print WLSTMessageBundle.getStringWithOneArg(WLSTMessageID.MSG_EXCEPTION, mbeanEx.getCause().getCause().getMessage())
else:
print WLSTMessageBundle.getStringWithOneArg(WLSTMessageID.MSG_EXCEPTION, mbeanEx)
except Exception, detail:
print 'Exception:', detail
# print WLSTMessageBundle.getStringWithOneArg(WLSTMessageID.MSG_EXCEPTION, detail)
def sca_checkWLSConnection2():
if (mbs is None):
# raise UserWarning, "No connection to a Weblogic server exists. This operation can be executed only in the online mode."
raise UserWarning, WLSTMessageBundle.getStringNoArg(WLSTMessageID.MBEAN_NO_CONNECTION)
def sca_getFolderMBean():
sca_checkWLSConnection2()
# serverMbName = ObjectName('oracle.soa.config:j2eeType=CompositeStore,name=online,*')
serverMbName = ObjectName('*:j2eeType=FolderLifecycleConfig,*')
beans = mbs.queryMBeans(serverMbName, None)
if beans != None and java.util.Iterator.hasNext(beans.iterator())==true:
return beans.iterator().next().getObjectName()
else:
# raise UserWarning, 'Cannot find folder lifecycle mbean on this server.'
raise UserWarning, WLSTMessageBundle.getStringNoArg(WLSTMessageID.FOLDER_MBEAN_NOT_FOUND)
# This command deletes the partition
#
# @partitionName The name of the partition
def sca_deletePartition(partitionName):
foldermbean = sca_getFolderMBean();
print 'partitionName =', partitionName
params = jarray.array([partitionName],java.lang.Object)
signature = jarray.array(['java.lang.String'],java.lang.String)
try:
# print 'Calling folder mbean to destroy partition...'
mbs.invoke(foldermbean, "destroy", params, signature)
# print 'Partition was successfully destroyed.'
print WLSTMessageBundle.getStringNoArg(WLSTMessageID.FOLDEDR_DESTROY_SUCCESS)
except MBeanException, mbeanEx:
if mbeanEx.getCause() != None and isinstance(mbeanEx.getCause(), InvocationTargetException) and mbeanEx.getCause().getCause() != None:
# print mbeanEx.getCause().getCause()
print WLSTMessageBundle.getStringWithOneArg(WLSTMessageID.MSG_EXCEPTION, mbeanEx.getCause().getCause().getMessage())
else:
print WLSTMessageBundle.getStringWithOneArg(WLSTMessageID.MSG_EXCEPTION, mbeanEx)
except Exception, detail:
# print 'Exception:', detail
print WLSTMessageBundle.getStringWithOneArg(WLSTMessageID.MSG_EXCEPTION, detail)
def main():
connect("soaUserName","soaPassword","t3://SOA Server HostName:SOA Server Port")
sca_createPartition("CRMSYNC");
sca_createPartition("CRMASYNC");
sca_createPartition("MEDIATOR");
sca_createPartition("UTILITIES");
disconnect()
print 'successfully created the partions'
main()

Attached soaManagePartition.py file for your reference.
soaManagePartition.py


Changing the Audit Level for Oracle SOA Suite

 Changing the Audit Level for Oracle SOA Suite 11g or Oracle SOA Suite 12c


SOA 11g has three different Audit levels – Production, Development and Off

Audit Level Details:

Audit Level
Description
Production(Default)
Composite instance tracking is collected, but Mediator engine will not collect payload details and BPEL engine will not collect payload details for assign activities (payload details for other BPEL activities are collected). This level is optimal for most normal production operations.
Development
Allows both the composite instance tracking and payload detail tracking. However it may impact the performance. This level is useful mostly for testing and debugging purposes.
Off
No logging is performed. Composite instance tracking and payload details are not collected.

Changing the Audit Level for SOA:

1. Login to EM console.
2. Expand the SOA folder and right-click the soa-infra and select SOA Administration – Click on Common Properties



Oracle SOA Suite – different user roles to restrict the access of EM console

Oracle SOA Suite – different user roles to restrict the access of EM console:

Not like oracle SOA Suite 10g, Oracle SOA Suite 11g or Oracle SOA Suite 12c is having different roles to restrict the access of the EM console.
Refer the below URL for the details about user roles for EM console.
Access to the Enterprise Manager console is determined by the role assigned to the user.
The steps to configure the different EM console roles to the user.

Through EM console

1. Create the corresponding users through weblogic console
2. Now log in to the Enterprise Manager console with admin privileges. Under SOA folder right-click on soa-infra and select Security -> Application Roles.




Thursday, October 27, 2011

Oracle SOA Suite – Getting the payload from the Composite instance through Java API - Part1


Oracle SOA Suite– Getting the payload from the Composite instance through Java API - Part1 

This blog explains the approach to retrieve the request payload from the closed composite instance.
The below code snippet will enable you to retrieve the request payload from the closed composite instance for Oracle SOA Suite 11g or Oracle SOA Suite 12c

import java.util.Hashtable;
import java.util.List;
import javax.naming.Context;
import oracle.soa.management.facade.ComponentInstance;
import oracle.soa.management.facade.CompositeInstance;
import oracle.soa.management.facade.Locator;
import oracle.soa.management.facade.LocatorFactory;
import oracle.soa.management.util.ComponentInstanceFilter;
import oracle.soa.management.util.CompositeInstanceFilter;

import org.w3c.dom.Document;
import org.w3c.dom.Node;

public class GetCompositeInstancePayload {
    //Invoke this method with the composite instance id
    public static String getCompositeInstancePayload(String compInstanceId, String ecid) {
        String compositeName = "GetOpenCompositeInstances";
        Hashtable jndiProps = new Hashtable();
        String inputPayload = "";
        try {
            jndiProps.put(Context.PROVIDER_URL, "t3://localhost:7201");
            jndiProps.put(Context.INITIAL_CONTEXT_FACTORY, "weblogic.jndi.WLInitialContextFactory");
            jndiProps.put(Context.SECURITY_PRINCIPAL, "weblogic");
            jndiProps.put(Context.SECURITY_CREDENTIALS, "Test1234");
            jndiProps.put("dedicated.connection", "true");
            Locator locator = LocatorFactory.createLocator(jndiProps);
            CompositeInstanceFilter filter = new CompositeInstanceFilter();
            filter.setECID(ecid); //Set the composite ECID
            List compositeInstance = locator.getCompositeInstances(filter);
            ComponentInstanceFilter instanceFilter = new ComponentInstanceFilter();
            instanceFilter.setCompositeInstanceId(compInstanceId);           
            List componentInstance =((CompositeInstance) compositeInstance.get(0)).getChildComponentInstances(instanceFilter);
            if (compositeInstance.size() > 0) {
                Document docAudit = XMLUtil.convertToDOM(((ComponentInstance) componentInstance.get(0)).getAuditTrail().toString());
                String payloadAudit = XPathUtils.executeXPath(docAudit, "//details").toString();
                Document docPayload = XMLUtil.convertToDOM(payloadAudit);
                Node payloadNode = XPathUtils.executeXPath(docPayload, "//part//*", "NODE");
                inputPayload = XMLUtil.nodeToString(payloadNode);
                System.out.println("InputPayload: "+ inputPayload);
            }
           
        } catch (Exception e) {
            e.printStackTrace();
        }
       
        return inputPayload;
    }

    public static void main(String[] args) {
       getCompositeInstancePayload("23","9897cfe2-ee70-44d6-9e40-9c77651c7025-00000783");
    }
}

XPathUtils:


Utility class to retrieve the XML payload from the instance audit trail.
import javax.xml.xpath.*;

import org.w3c.dom.*;

public class XPathUtils {
    public static Object executeXPath(Document doc, String xpathStr) throws Exception {
        XPath xpath = null;
        String value = null;
        try {
            xpath = new org.apache.xpath.jaxp.XPathFactoryImpl().newXPath();
            XPathExpression expr = xpath.compile(xpathStr);
            value = (String) expr.evaluate(doc, XPathConstants.STRING);
            return value;
        } catch (Exception e) {
            throw e;
        }
    }

    public static Node executeXPath(Document doc, String xpathStr, String type) throws Exception {
        XPath xpath = null;
        Node value = null;
        try {
            xpath = new org.apache.xpath.jaxp.XPathFactoryImpl().newXPath();
            XPathExpression expr = xpath.compile(xpathStr);
            value = (Node) expr.evaluate(doc, XPathConstants.NODE);
            return value;
        } catch (Exception e) {
            throw e;
        }
    }
}