Friday, September 14, 2012

Difference between BPEL 1.1 and BPEL 2.0 – Oracle SOA Suite

Difference between BPEL 1.1 and BPEL 2.0 – Oracle SOA Suite 11g:

Oracle SOA Suite 11g and Oracle SOA Suite 12c provides the option to use both the BPEL 1.1 and BPEL 2.0 versions.
If we are migrating the BPEL process from 10g to 11g version the BPEL 1.1 version will be used in the migrated process but new processes can be developed in BPEL 2.0.


New Activities 2.0

  • <forEach> activity to repeat the set of activities . Replace the FlowN activity in BPEL 1.1 version.
  • <repeatUntil> - Use this activity if the body of an activity must be performed at least once. The XPath expression condition in the repeatUntil activity is evaluated after the body of the activity completes.
  •  <if>-<elseif>-<else> - Replaces the switch activity in BPEL 2.0 - This activity enables you to define conditional behavior for specific activities to decide between two or more branches. Only one activity is selected for execution from a set of branches.
  • Changed <terminate> to <exit>
  • <compensateScope>  - to compensate the specified child scope
  • A <rethrow> activity has been added to fault handlers this activity enables you to rethrow a fault originally captured by the immediately enclosing fault handler.

weblogic.socket.MaxMessageSizeExceededException appearing when Managed Server Attempting To Send larger message to Admin Server.

weblogic.socket.MaxMessageSizeExceededException appearing when Managed Server Attempting To Send larger message to Admin Server.


We used to get the following exception in the weblogic managed servers log file frequently

 ####<Mar 20, 2012 12:22:47 PM EST> <Error> <Socket> <ifappc105p> <AdminServer> <ExecuteThread: '2' for queue: 'weblogic.socket.Muxer'> <> <> <a33374ea6b7bab0f:17f6d3b7:1343f18f4ea:-8000-000000000000008a> <1323912167710> <BEA-000403> <IOException occurred on socket: Socket[addr=ifappc105p-vip1/172.105.200.105,port=8000,localport=55103]
weblogic.socket.MaxMessageSizeExceededException: Incoming message of size: '10000480' bytes exceeds the configured maximum of: '10000000' bytes for protocol: 't3'.
weblogic.socket.MaxMessageSizeExceededException: Incoming message of size: '10000480' bytes exceeds the configured maximum of: '10000000' bytes for protocol: 't3'
at weblogic.socket.BaseAbstractMuxableSocket.incrementBufferOffset(BaseAbstractMuxableSocket.java:174)
at weblogic.rjvm.t3.MuxableSocketT3.incrementBufferOffset(MuxableSocketT3.java:351)


The reason is the weblogic managed server tries to send the message size more than 10 MB and failing with the following exception. It is observed that every single time this message is observed in the logs, it is followed by the respective managed server who is sending that message, losing connectivity with the admin server.

The root cause is the RJVM messages used to get piled up due to default watches trap events that’s comes installed and it used to grow in larger size causing the broken communication between managed servers and AdminServer

The solution to resolve this is to disable the default WLDF configured in the server.

Steps to disable the default WLDF configured in the server

  • Login into admin console with weblogic user.
  • Click Lock & Edit
  • Expand Diagnostics tab 

  • Click on Diagnostic Modules

Friday, September 7, 2012

Java code to retrieve the node data from a XML string received from a web URL

Java code to retrieve the node data from a XML string received from a web URL:

Code:

import java.io.*;
import java.net.*;
import javax.xml.parsers.*;
import org.w3c.dom.*;

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

    public static void getResponse(String city) {

        HttpURLConnection connection = null;
       
        String url="http://feeds.feedburner.com/burrp/"+city+"-events/weekend?format=xml";

        try {
            connection =
                    (HttpURLConnection)new URL(url).openConnection();
            connection.setRequestProperty("content-type",
                                          "text/xml;charset=utf-8");
            connection.setRequestMethod("GET");
            connection.setDoInput(true);
            connection.setDoOutput(true);

            InputStream is = connection.getInputStream();
            BufferedReader rd = new BufferedReader(new InputStreamReader(is));

            String line;
            StringBuffer response = new StringBuffer();
            while ((line = rd.readLine()) != null) {
                response.append(line);
                response.append('\r');
            }
           
            rd.close();
           
            DocumentBuilderFactory docBuilderFactory = DocumentBuilderFactory.newInstance();
            docBuilderFactory.setNamespaceAware(false);
            DocumentBuilder docBuilder = docBuilderFactory.newDocumentBuilder();
            InputStream is1 = new ByteArrayInputStream(response.toString().getBytes());
            Document doc = docBuilder.parse (is1);
            doc.getDocumentElement ().normalize ();
            NodeList listOfChannels = doc.getElementsByTagName("description");
            String description=listOfChannels.item(1).getFirstChild().getNodeValue();
            System.out.println(description);

        } catch (FileNotFoundException e) {
           
        }
        catch (Exception e) {
            e.printStackTrace();
        } finally {

        }
    }

    public static void main(String[] args) {

        getResponse("Chennai");

    }
}

Modifying the targets of JDBC datasources through WLST script in weblogic server

Modifying the targets of JDBC datasources through WLST script in weblogic server

This tutorial explains the details on WLST script to change or add the targets for JDBC data sources in weblogic server.

The targeting can be enabled through weblogic admin console but the script helps us to automate the server configurations and reduce the manual effort if multiple data-sources need to be configured.
wlst-modify-jdbc-datasource-targets
The script will target the server MS3 and the Cluser1 to the data source with name “CRM6EAIReference”

Define JDBCProperties.properties with required configurations(sample script to show the configuration for multiple data-sources)

domain1.total.DS=2
domain1.prefix.1=om
domain1.om.datasource.name.1=CRM6EAIReference
domain1.om.datasource.target.1=Clusters/Cluster1,Servers/MS3
domain1.prefix.2=soa
domain1.soa.datasource.name.2=CRM6EAISOAMetadataSource
domain1.soa.datasource.target.2=Clusters/SOACluster

Before executing the script change the properties as required.If the target is a Server then it should be added like Servers/ServerName and if it is a cluster then it should be defined as Clusters/ClusterName. Configure domain1.total.DS with total number of data sources need to be configured.

Let us now define a WLST script file to change the targets using the property file defined above.

import re
from java.io import FileInputStream   

def UntargetTargetJDBCResources():
    edit()
    startEdit()
    propInputStream = FileInputStream('JDBCProperties.properties')
    configProps = Properties()
    configProps.load(propInputStream)    

    totalDataSource_to_untargetTarget=configProps.get("domain1.total.DS")
    
    server='AdminServer'
    cd("Servers/"+server)
       
    i=1
    while (i <= int(totalDataSource_to_untargetTarget)) :
    prefix = configProps.get("domain1.prefix."+ str(i))
    dsName = configProps.get("domain1."+prefix+".datasource.name."+ str(i))
    datasourceTargets = re.split(",",configProps.get("domain1."+prefix+".datasource.target."+ str(i)))
    targetArray=[] 
    
    for datasourceTarget in datasourceTargets:
   print 'DataSourceTargets',datasourceTargets
   print 'DataSourceTarget',datasourceTarget
   if datasourceTarget=='':
    print ''
   else:
    cd ('/JDBCSystemResources/'+dsName)
    set('Targets',jarray.array([], ObjectName))
    target=datasourceTarget[datasourceTarget.index("/")+1:len(datasourceTarget)]       
    if datasourceTarget.startswith('Cluster'):
     targetArray.append(ObjectName('com.bea:Name='+target+',Type=Cluster'))     
    elif datasourceTarget.startswith('Server'):
     targetArray.append(ObjectName('com.bea:Name='+target+',Type=Server'))         
   
    print 'Targets: ',targetArray
    set('Targets',jarray.array(targetArray, ObjectName))
    print 'DataSource: ',dsName,',Target has been updated Successfully !!!'
    print '========================================='    
    i = i + 1

    print '========================================='
    save()
    activate()
def main():
    adminURL='t3://localhost:7001'
    adminUserName='weblogic'
    adminPassword='weblogic1'
    connect(adminUserName, adminPassword, adminURL)
    UntargetTargetJDBCResources();
    print 'Successfully Modified the JDBC resources'
    disconnect()
main()

Script - 

The above script update the JDBC data source targets based on the configurations enabled in the property file.

Execute the script — <<Oracle_Home>>\oracle_common\common\bin\wlst.cmd ModifyJDBCResourcesTargets.py
wlst-modify-jdbc-datasource-targets
The JDBC data source targets changed now with the enabled configurations,the WLST script can be used to automate the server configurations and reduce the manual effort need for configurations.

Wednesday, September 5, 2012

Creating Socket Adapter connection factories through WLST script - Oracle SOA Suite

Creating Socket Adapter connection factories through WLST script - Oracle SOA Suite

The below WLST script will help us to create the Socket adapter connection factories in Oracle SOA Suite 11g or Oracle SOA Suite 12c

Change the Socket/SOA server details accordingly in the script.

Before executing the script make sure the SocketAdapter is targeted to the servers.

socket_adapter_target_servers

CreateSocketConnectionFactory.py

TargetServerName='AdminServer'

soaHome='C:\EnvSetup\MiddlewareBlog\Oracle_SOA1'

appPathSock=soaHome+'\soa\connectors\SocketAdapter.rar'
appNameSock='SocketAdapter'
moduleOverrideNameSock=appNameSock+'.rar'
SockJNDIName = 'eis/socket/SocketAdapterBlog'
#Socket Sever Details
HostName='101.63.203.129'
Password='blogenv1'
Port='7001'
UserName='weblogic'

moduleDescriptorName='META-INF/weblogic-ra.xml'
planPathSock='C:\EnvSetup\MiddlewareBlog\Oracle_SOA1\soa\connectors\Plan_Soket.xml'

def createSocketConnectionFactory(): 

        edit()
        startEdit()
        startApplication(appNameSock)
        myPlanSock=loadApplication(appPathSock, planPathSock)
        makeDeploymentPlanVariable(myPlanSock,'ConnectionInstance_eis/Socket_JNDIName_13102979357209', SockJNDIName , '/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="javax.resource.cci.ConnectionFactory"]/connection-instance/[jndi-name="'+SockJNDIName+'"]/jndi-name',moduleOverrideNameSock)
        makeDeploymentPlanVariable(myPlanSock, 'ConfigProperty_eis/Socket_JNDIName_Host_Name_13102979357210', HostName,'/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="javax.resource.cci.ConnectionFactory"]/connection-instance/[jndi-name="'+SockJNDIName+'"]/connection-properties/properties/property/[name="Host"]/value',moduleOverrideNameSock)
        makeDeploymentPlanVariable(myPlanSock, 'ConfigProperty_eis/Socket_JNDIName_Port_13102979357212', Port,'/weblogic-connector/outbound-resource-adapter/connection-definition-group/[connection-factory-interface="javax.resource.cci.ConnectionFactory"]/connection-instance/[jndi-name="'+SockJNDIName+'"]/connection-properties/properties/property/[name="Port"]/value',moduleOverrideNameSock)
               
        myPlanSock.save();
        save();
        cd('/AppDeployments/SocketAdapter/Targets');
        updateApplication(appNameSock, planPathSock);
        startApplication(appNameSock);
        activate(block='true');
      
   
def makeDeploymentPlanVariable(wlstPlan, name, value, xpath,overrideName, origin='planbased'):
    wlstPlan.destroyVariable(name)
    wlstPlan.destroyVariableAssignment(name, overrideName, moduleDescriptorName)
    variableAssignment = wlstPlan.createVariableAssignment(name, overrideName, moduleDescriptorName)
    variableAssignment.setXpath(xpath)
    variableAssignment.setOrigin(origin)
    wlstPlan.createVariable(name, value)
    print 'moduleDescriptorName=',moduleDescriptorName


def main():
       #SOA Server Details
       adminURL='t3://localhost:7001'
       adminUserName='weblogic'
       adminPassword='blogenv1'
       connect(adminUserName, adminPassword, adminURL)
       createSocketConnectionFactory()
       disconnect()
main()

Login to the server, cd to the folder where the script is available and execute the script as shown below.

%MIDDLEWARE_HOME%\wlserver_10.3\common\bin\wlst.cmd CreateSocketConnectionFactory.py




DOWNLOAD  CreateSocketConnectionFactory.py