Archive

Archive for August, 2012

SOA 11G MDS Deployment through ANT Script

August 25, 2012 Leave a comment

Here I have given the ANT script to deploy shared resources to MDS.

This script can be used to deploy all shared resources to MDS or
to deploy particular folder to MDS.
 
1. My MDS Folder structure
 

MDSFolderStructure

MDSFolderStructure


 

2. Resource structure of MDS Deployment
 
The below is the way I have kept the resources to be deployed to MDS while executing the Ant script.
 
Inside the MDS folder , I have followed same folder structure as mentioned above.
 

MDSDeploymentStructure

MDSDeploymentStructure

 

3. build.properties
 

mds.application=mds-application
# mds.all key is for deployment
mds.all=MDS/apps
# specify the path for undeploying MDS resources
#example like (/apps/int/util/DVM or /apps/int/util/resources)
#mds.folderName=
# Specify the path to place MDS backup as jar
#mds.export.backup.dir=
#SOA 11G installation location
wls.bea.home=C:/Saba/soa11g/soa11.1.1.5/Middleware
oracle.home=${wls.bea.home}/Oracle_SOA1
java.passed.home=${wls.bea.home}/jdk160_24
wl.home=${wls.bea.home}/wlserver_10.3
#Admin Server Hostname and Port number
admin.server.host=localhost
admin.server.port=7011
# connection information for the managed server, used for soa-deployment
managed.server.host=localhost
managed.server.port=8011
# User and credentials for the servers
server.user=weblogic
server.password=welcome1

 
4. build.xml
 

<?xml version="1.0" encoding="UTF-8" ?>
<project name="mds-application" default="display" basedir=".">    
	<!-- build.properties -->
	<property file="build.properties" />
	<property name="deploy.dir" value="${basedir}/deploy" />
	<property name="mds.deploy.dir" value="${deploy.dir}" />
	<property name="mds.faultpolicies.dir" value="int/util/fault-policies" />
	<property name="mds.dvm.dir" value="int/util/DVM" />
	<property name="mds.xref.dir" value="int/util/XREF" />
	<property name="mds.schema.dir" value="int/util/resources" />
	<property name="mds.soaConstant.dir" value="int/util/constants" />
	
	<!-- This will display the targets available -->
	<target name="display">
		<input message="Please enter target to Run MDS" addproperty="target" defaultvalue="deployAll" validargs="deployAll,deployFaultPolicy,deployDVM,deployXREF,deployXSDWSDL,deploySOAConstant,undeployMDS,exportMDS" />
		<antcall target="${target}"/>
	</target>
	
	<target name="clean">
		<echo>remove and create local MDS temp</echo>
		<delete dir="${mds.deploy.dir}"/>	
	</target>
	<target name="init" depends="clean">
		<echo>remove and create local MDS temp</echo>
		<mkdir dir="${mds.deploy.dir}"/>	
	</target>
	
	<target name="buildAll" depends="init">
		<echo>+++++++ copy required files to ${mds.deploy.dir} +++++++++</echo>
		<copy todir="${mds.deploy.dir}" verbose="true" overwrite="true">
			<fileset dir="${basedir}/${mds.all}/" includes="**/*"/>
		</copy>               
		<echo>create zip from file MDS store</echo>
		<zip destfile="${mds.deploy.dir}/${mds.application}.jar" compress="false">         
			<fileset dir="${mds.deploy.dir}" includes="**/*" />
		</zip>
		<echo>create zip with MDS jar</echo>
		<zip destfile="${mds.deploy.dir}/${mds.application}.zip" compress="false">
			<fileset dir="${mds.deploy.dir}" includes="*.jar" />
		</zip>	
	</target>
	
	<target name="buildFaultPolicy" depends="init">
		<echo>+++++++ copy required files to ${mds.deploy.dir} +++++++++</echo>
		<copy todir="${mds.deploy.dir}" verbose="true" overwrite="true">
			<fileset dir="${basedir}/${mds.all}/" includes="**/${mds.faultpolicies.dir}/**"/>
		</copy>               
		<echo>create zip from file MDS store</echo>
		<zip destfile="${mds.deploy.dir}/${mds.application}.jar" compress="false">         
			<fileset dir="${mds.deploy.dir}" includes="**/*" />
		</zip>
		<echo>create zip with MDS jar</echo>
		<zip destfile="${mds.deploy.dir}/${mds.application}.zip" compress="false">
			<fileset dir="${mds.deploy.dir}" includes="*.jar" />
		</zip>	
	</target>
	
	<target name="buildDVM" depends="init">
		<echo>+++++++ copy required files to ${mds.deploy.dir} +++++++++</echo>
		<copy todir="${mds.deploy.dir}" verbose="true" overwrite="true">
			<fileset dir="${basedir}/${mds.all}/" includes="**/${mds.dvm.dir}/**"/>
		</copy>               
		<echo>create zip from file MDS store</echo>
		<zip destfile="${mds.deploy.dir}/${mds.application}.jar" compress="false">         
			<fileset dir="${mds.deploy.dir}" includes="**/*" />
		</zip>
		<echo>create zip with MDS jar</echo>
		<zip destfile="${mds.deploy.dir}/${mds.application}.zip" compress="false">
			<fileset dir="${mds.deploy.dir}" includes="*.jar" />
		</zip>	
	</target>
	
	<target name="buildXREF" depends="init">
		<echo>+++++++ copy required files to ${mds.deploy.dir} +++++++++</echo>
		<copy todir="${mds.deploy.dir}" verbose="true" overwrite="true">
			<fileset dir="${basedir}/${mds.all}/" includes="**/${mds.xref.dir}/**"/>
		</copy>               
		<echo>create zip from file MDS store</echo>
		<zip destfile="${mds.deploy.dir}/${mds.application}.jar" compress="false">         
			<fileset dir="${mds.deploy.dir}" includes="**/*" />
		</zip>
		<echo>create zip with MDS jar</echo>
		<zip destfile="${mds.deploy.dir}/${mds.application}.zip" compress="false">
			<fileset dir="${mds.deploy.dir}" includes="*.jar" />
		</zip>	
	</target>
	
	<target name="buildXSDWsdl" depends="init">
		<echo>+++++++ copy required files to ${mds.deploy.dir} +++++++++</echo>
		<copy todir="${mds.deploy.dir}" verbose="true" overwrite="true">
		     <fileset dir="${basedir}/${mds.all}/" includes="**/${mds.schema.dir}/**"/>
		</copy>               
		<echo>create zip from file MDS store</echo>
		<zip destfile="${mds.deploy.dir}/${mds.application}.jar" compress="false">         
		    <fileset dir="${mds.deploy.dir}" includes="**/*" />
		</zip>
		<echo>create zip with MDS jar</echo>
		<zip destfile="${mds.deploy.dir}/${mds.application}.zip" compress="false">
			<fileset dir="${mds.deploy.dir}" includes="*.jar" />
		</zip>	
	</target>
	
	<target name="buildSOAConstant" depends="init">
		<echo>copy required files to ${mds.deploy.dir}</echo>
		<copy todir="${mds.deploy.dir}" verbose="true" overwrite="true">
			<fileset dir="${basedir}/${mds.all}/" includes="**/${mds.soaConstant.dir}/**"/>
		</copy>               
		<echo>create zip from file MDS store</echo>
		<zip destfile="${mds.deploy.dir}/${mds.application}.jar" compress="false">         
			<fileset dir="${mds.deploy.dir}" includes="**/*" />
		</zip>
		<echo>create zip with MDS jar</echo>
		<zip destfile="${mds.deploy.dir}/${mds.application}.zip" compress="false">
			<fileset dir="${mds.deploy.dir}" includes="*.jar" />
		</zip>	
	</target>
	
	<target name="genericDeployer">
		<echo>deploy MDS application ${mds.application}</echo>
		<echo>deploy on	http://${managed.server.host}:${managed.server.port}/soa-infra/deployer	with user ${server.user}</echo>
		<echo>deploy sarFile ${mds.deploy.dir}\${mds.application}.zip</echo>
		<ant antfile="${oracle.home}/bin/ant-sca-deploy.xml" inheritAll="false"	target="deploy">
			<property name="wl_home" value="${wl.home}" />
			<property name="oracle.home" value="${oracle.home}" />
			<property name="serverURL" value="http://${managed.server.host}:${managed.server.port}/soa-infra/deployer"/>
			<property name="user" value="${server.user}" />
			<property name="password" value="${server.password}" />
			<property name="overwrite" value="true" />
			<property name="forceDefault" value="false" />
			<property name="sarLocation" value="${mds.deploy.dir}/${mds.application}.zip"/>
		</ant>
	</target>
	
	<!-- This target is to deploy all required sources to MDS -->
	<target name="deployAll" depends="buildAll">
		<antcall target="genericDeployer"/>
	</target>
	
	<!-- This target is to deploy fault-policies files to MDS -->
	<target name="deployFaultPolicy" depends="buildFaultPolicy">
		<antcall target="genericDeployer"/>
	</target>
	
	<!-- This target is to deploy DVM files to MDS -->
	<target name="deployDVM" depends="buildDVM">
		<antcall target="genericDeployer"/>
	</target>
	
	<!-- This target is to deploy XREF files to MDS -->
	<target name="deployXREF" depends="buildXREF">
		<antcall target="genericDeployer"/>
	</target>
	
	<!-- This target is to deploy Schemas and WSDLs files to MDS -->
	<target name="deployXSDWSDL" depends="buildXSDWsdl">
		<antcall target="genericDeployer"/>
	</target>
	
	<!-- This target is to deploy SOA Constants file to MDS -->
	<target name="deploySOAConstant" depends="buildSOAConstant">
		<antcall target="genericDeployer"/>
	</target>
	
	<target name="undeployMDS">
		<echo>undeploy MDS application ${mds.application}</echo>
		<ant antfile="${oracle.home}/bin/ant-sca-deploy.xml" inheritAll="false"	target="removeSharedData">
			<property name="wl_home" value="${wl.home}" />
			<property name="oracle.home" value="${oracle.home}" />
			<property name="serverURL" value="http://${managed.server.host}:${managed.server.port}/soa-infra/deployer"/>
			<property name="user" value="${server.user}" />
			<property name="password" value="${server.password}" />
			<property name="folderName" value="${mds.folderName}" />
		</ant>
	</target>
	<target name="exportMDS">
	    <tstamp>
	      <format property="start.timestamp" pattern="yyyy-MM-dd_HHmm" />
	    </tstamp>
	    <echo>
		================================================================================
			EXPORT MDS: ${local.mds.export}/MDSbackup.${start.timestamp}.jar
		================================================================================
	    </echo>
	    <ant antfile="${oracle.home}/bin/ant-sca-deploy.xml" inheritAll="false" target="exportSharedData">
	      <property name="serverURL"        value="${serverURL}"/>
	      <property name="jarFile"          value="${mds.export.backup.dir}/MDSbackup.${start.timestamp}.jar"/>
	      <property name="pattern"          value="**"/>
	      <property name="user"             value="${server.user}"/>
	      <property name="password"         value="${server.password}"/>
	    </ant>
	  </target>
</project>
Advertisements

How to disable BAM from EM Console

August 24, 2012 Leave a comment

We can disable Oracle BAM sensor data publishing from EM console completely or particular composite. For example In performace testing if you face any problem while publishing sensor data to BAM Server, you can disable the BAM Sensor publishing from EM Console and continue the performance test without restarting the SOA servers.

Disable BAM Sensor data publishing completely from all the composites
1. Login into EM Console
2. Expand SOA , Right Clik soa-infra(soa_server1) , Select SOA Administration and Click on BPEL Properties
3. Check Disable BPEL Monitors and Sensors option to disable the sensor.
 

DisableBAMSensorFromEM

DisableBAMSensorFromEM

 
Disable BAM Sensor data publishing from particular Composite
1. Select particular composite
2. Select Settings –> Click on Enable/Disable Business Monitoring..
3. Choose Disable All to disable sensor for particular composite.

 

DisableBAMInComposite

DisableBAMInComposite

 

DisableBAM

DisableBAM

Categories: BAM Tags: , , ,

Import, Export, Delete Files from MDS

August 16, 2012 Leave a comment

Oracle SOA 11G MDS used as a shared repository for managing and reusing shared resources like WSDL, XSD, DVM, XREF, FAULT-POLICIES and CONSTANTS across applications.

Here below are the WLST commands to import , export and delete contents from MDS

1. Execute wlst.cmd :


cd ${ORACLE_HOME}/oracle_common/common/bin

Execute wlst.sh file:
----------------------
wlst.sh

 
2. Connect to WL Server :


connect('weblogic','welcome1','t3://localhost:7011')

 
3. Import Contents to MDS :


Import all files and folder :
-----------------------------
importMetadata(application='soa-infra',server='soa_server1',
               fromLocation='C:/Saba/soa11g/mds/',docs='/apps/**')

Import files under specified directory to MDS:
----------------------------------------------
importMetadata(application='soa-infra',server='soa_server1',
           fromLocation='C:/Saba/soa11g/mds/',docs='/apps/util/DVM/**')
importMetadata(application='soa-infra',server='soa_server1',
           fromLocation='C:/Saba/soa11g/mds/',docs='/apps/util/XREF/**')

Import specific file to MDS:
---------------------------------
importMetadata(application='soa-infra',server='soa_server1',
               fromLocation='C:/Saba/soa11g/mds/',
               docs='/apps/util/DVM/COUNTRYCODE.dvm')

 

4. Export Contents from MDS :


Export all files and folders from MDS:
--------------------------------------
exportMetadata(application='soa-infra', server='soa_server1',
               toLocation='C:/Saba/soa11g/mds/', docs='/**')

Export all files and folders inside "/apps" folder :
----------------------------------------------------
exportMetadata(application='soa-infra', server='soa_server1',
              toLocation='C:/Saba/soa11g/mds/', docs='/apps/**')

Export specific folder :
-----------------------
exportMetadata(application='soa-infra', server='soa_server1',
               toLocation='C:/Saba/soa11g/mds/', 
               docs='/apps/util/fault-policies/**')
exportMetadata(application='soa-infra', server='soa_server1',
           toLocation='C:/Saba/soa11g/mds/', docs='/apps/util/DVM/**')
exportMetadata(application='soa-infra', server='soa_server1',
           toLocation='C:/Saba/soa11g/mds/', docs='/apps/util/XREF/**')

Export specific file:
---------------------
exportMetadata(application='soa-infra', server='soa_server1',
               toLocation='C:/Saba/soa11g/mds/',
               docs='/apps/util/DVM/COUNTRYCODE.dvm')

 
5. Delete Contents from MDS :


Delete all files:
-----------------------------
deleteMetadata(application='soa-infra',server='soa_server1',docs='/apps/')

Delete files under specific folder:
-----------------------------------
deleteMetadata(application='soa-infra',server='soa_server1',
               docs='/apps/util/DVM')

Delete specific file:
---------------------
deleteMetadata(application='soa-infra',server='soa_server1',
               docs='/apps/util/DVM/COUNTRYCODE.dvm')

 
5. Delete Folder from MDS :


1. Go to ${ORACLE_HOME}/Oracle_SOA1/common/bin
2. Execute wlst.sh file.
3. wls:/offline>connect('weblogic','welcome1','t3://localhost:7011')
4. wls:/SOA-domain/serverConfig> sca_removeSharedData('http://localhost:8011',
                                    'DVM')
Example: sca_removeSharedData('http://<ManagerServerHost>:<ManagedServerPort>',
                              'DVM')

Just mention the any folder name inside root folder "/apps", that folder 
and files inside that folder will be deleted.

Categories: MDS Tags: , , , ,

SOA 11G: Timeout Settings

August 10, 2012 Leave a comment

1. How to set syncMaxWaitTime
 
1. Login into EM Console. (http://localhost:7011/em)
2. Expand SOA , right click on soa-infra and select SOA Administration –> BPEL Properties. It will Open BPEL Properties.
 

BPELProperties

BPELProperties


 

BPELProperties

BPELProperties

 
3. Click on More Configuration Properties… link and update the syncMaxWaitTime.
 

SystemMBeanBrowser

SystemMBeanBrowser

 

To increase the BPEL timeout settings , remember this rule.
 
syncMaxWaitTime < BPEL EJB's transaction timeout < Global Transaction Timeout
 

4. BPEL EJB’s Transaction timeout
4.1. Login into Weblogic Console –> Deployments –> soa-infa –>ejb
 

EJBTransactionTimeout

EJBTransactionTimeout

 
5. Set Global Transaction Timeout
 
5.1. Login to Weblogic Console , Click On domain then select Configuration and JTA.
 

GlobalTransactionTimeout

GlobalTransactionTimeout

SOA 11G: Composites Deployment using ANT

August 8, 2012 Leave a comment

Here I have given the ANT script for soa 11g composites depoyment by reading the entry from the text file. We can use this ant script to deploy multiple composite project in a shot. This ant script will read the text file line by line and deploy the projects.

1.build.properties


project.file.name=ProcessList.txt
wls.bea.home=/u01/oracle/product/fmw/soa11.1.1.6
wl_home=${wls.bea.home}/wlserver_10.3
oracle.home=${wls.bea.home}/Oracle_SOA1
java.home=/u01/oracle/product/jdk/jdk1.6.0_30

#Weblogic server username and password
server.user=weblogic
server.password=welcome1
#serverURL=http://:
serverURL=http://localhost:8011
#server.host=
server.host=localhost
#server.port=
server.port=8011

 
2.ProcessList.txt file structure


{processName},{partition},{version},{Is it default process},{project location from where the build.xml is}
SayHello,default,1.0.0,true,applications/sample/SayHello

 
3.build.xml

<?xml version="1.0" encoding="iso-8859-1"?>
<project name="soaDeployAll" basedir="." default="help">
  <property environment="env"/>
  <property name="sca.location" value="${basedir}/"/>
	<path id="classpath">
		<!-- To refer the all the jars inside folder lib-->
		<fileset dir="${basedir}/lib">
			<include name="**/*.jar"/>
		</fileset>
	</path>
 <taskdef resource="net/sf/antcontrib/antcontrib.properties" uri="http://ant-contrib.sourceforge.net">
  	<classpath>
  		<pathelement location="${basedir}/lib/ant-contrib-1.0b3.jar"/>
  	</classpath>
  </taskdef>
  <taskdef resource="net/sf/antcontrib/antlib.xml">
  	<classpath>
  	  		<pathelement location="${basedir}/lib/ant-contrib-1.0b3.jar"/>
  	  	</classpath>
  </taskdef>


  <!-- ================================================================================ -->
  <!-- TARGET: help                                                                     -->
  <!-- ================================================================================ -->

  <target name="help">
    <echo>
    Usable targets are:

    help                   - This help
    deployComposites       - Packages and deploys composites in 'ProcessList.txt'
    undeployComposites     - Undeploys composites in 'ProcessList.txt'
    listDeployedComposites - Lists deployed composites
	------------------------------------------------------
   	|	Usage example:                                  |
    ------------------------------------------------------

    export ORACLE_HOME=${oracle.home}
    export ANT_HOME=${ORACLE_HOME}/modules/org.apache.ant_1.7.1
    export PATH=${ANT_HOME}/bin:$PATH
    export CURRENT_FOLDER=`pwd`
    export JAVA_HOME=${ORACLE_HOME}/jdk1.6.0_21

    ant help -verbose
    ant deployComposites -verbose
    ant undeployComposites -verbose
    ant listDeployedComposites -verbose

    </echo>

  </target>


  <!-- ================================================================================ -->
  <!-- Check for an load property files                                                 -->
  <!-- ================================================================================ -->

  <available file="build.properties" property="file.exists" value="true" />
  <fail unless="file.exists" message="ERROR: Filename 'build.properties' does not exist." />
  <property file="build.properties"/>  
  <!-- ================================================================================ -->
  <!-- TARGET: deployComposites                                                         -->
  <!-- ================================================================================ -->

  <target name="deployComposites">
	
    <available file="${project.file.name}" property="file.exists" value="true" />
    <fail unless="file.exists" message="ERROR: Filename '${project.file.name}' does not exist."/>
    <loadfile property="allprocesses" srcFile="${project.file.name}"/>

    <var name="errorCount" value="0"/>
    <var name="processCount" value="0"/>
    <var name="errorProcessNames" value="(none)"/>
  	<if>
  		<equals arg1="${replace.env.prop}" arg2="true"/>
  		<then>
  			<antcall target="replace"/>
  		</then>
  	</if>
  	
    <trycatch property="tryName" reference="exception_ref">
      <try>
        <for list="${allprocesses}" param="processName" delimiter="${line.separator}">
          <sequential>
  	     <propertyregex property="composite.name"      input="@{processName}" regexp="([^,]+),([^,]+),([^,]+),([^,]+),([^,]+)" select="\1" override="true"/>
            <propertyregex property="composite.partition" input="@{processName}" regexp="([^,]+),([^,]+),([^,]+),([^,]+),([^,]+)" select="\2" override="true"/>
            <propertyregex property="composite.revision"  input="@{processName}" regexp="([^,]+),([^,]+),([^,]+),([^,]+),([^,]+)" select="\3" override="true"/>
            <propertyregex property="default.composite"   input="@{processName}" regexp="([^,]+),([^,]+),([^,]+),([^,]+),([^,]+)" select="\4" override="true"/>
            <propertyregex property="project.loctaion"         input="@{processName}" regexp="([^,]+),([^,]+),([^,]+),([^,]+),([^,]+)" select="\5" override="true"/>
            <math result="processCount" operand1="${processCount}" operation="+" operand2="1" datatype="int"/>
			
            <echo>
			 ===================================================================================
				PACKAGE COMPOSITE #${processCount}: ${composite.name} ${composite.revision}
			 ===================================================================================
            </echo>
            <copy todir="${basedir}/${project.loctaion}/SCA-INF/classes/META-INF/" file="${basedir}/includes/adf-config.xml" overwrite="true"/>
          	
            <ant antfile="${oracle.home}/bin/ant-sca-package.xml" target="package" inheritall="false">
              <property name="oracle.home" value="${oracle.home}"/>	
              <property name="compositeDir" value="${basedir}/${project.loctaion}"/>
              <property name="scac.application.home" value="${basedir}/${project.loctaion}"/>
              <property name="scac.input" value="${basedir}/${project.loctaion}/composite.xml"/>
              <property name="compositeName" value="${composite.name}"/>
              <property name="revision" value="${composite.revision}"/>
              <property name="java.passed.home" value="${java.home}"/>
              <property name="wl_home" value="${wl_home}"/>
            </ant>

            <echo>
			 ================================================================================
				 DEPLOY COMPOSITE #${processCount}: ${composite.name} 
			 ================================================================================
            </echo>
            <ant antfile="${oracle.home}/bin/ant-sca-deploy.xml" target="deploy" inheritall="false">
              <property name="user" 		value="${server.user}"/>
              <property name="password" 	value="${server.password}"/>
              <property name="serverURL" 	value="${serverURL}/soa-infra/deployer"/>
              <property name="sarLocation" 	value="${basedir}/${project.loctaion}/deploy/sca_${composite.name}_rev${composite.revision}.jar"/>
              <property name="overwrite" 	value="true"/>
              <!--<property name="configplan" 	value="${basedir}/${project.loctaion}/${composite.name}_cfgplan.xml"/>-->
            </ant>

            <sleep seconds="3" />
          </sequential>
        </for>
      </try>
      <catch>
        <property name="exception" refid="exception_ref" />
        <property name="message" value="ERROR IN TRYCATCH BLOCK:${line.separator}${exception}" />
        <echo></echo>
        <echo message="${message}" />
        <math result="errorCount" operand1="${errorCount}" operation="+" operand2="1" datatype="int"/>
        <var name="errorProcessNames" value="${composite.name}"/>
      </catch>
    </trycatch>

    <echo>
		**************************************************************
		*  ANT TARGET NAME	: deployComposites
		*  FAILED PROCESS	: ${errorProcessNames}
		*
		**************************************************************
    </echo>
  </target>


  <!-- ================================================================================ -->
  <!-- TARGET: undeployComposites                                                       -->
  <!-- ================================================================================ -->

  <target name="undeployComposites">

    <available file="${project.file.name}" property="file.exists" value="true" />
    <fail unless="file.exists" message="ERROR: Filename '${project.file.name}' does not exist." />
    <loadfile property="allprocesses" srcFile="${project.file.name}"/>

    <var name="errorCount" value="0"/>
    <var name="processCount" value="0"/>
    <var name="errorProcessNames" value="*"/>

    <for list="${allprocesses}" param="processName" delimiter="${line.separator}">
      <sequential>
        <propertyregex property="composite.name"      input="@{processName}" regexp="([^,]+),([^,]+),([^,]+),([^,]+),([^,]+)" select="\1" override="true"/>
        <propertyregex property="composite.partition" input="@{processName}" regexp="([^,]+),([^,]+),([^,]+),([^,]+),([^,]+)" select="\2" override="true"/>
        <propertyregex property="composite.revision"  input="@{processName}" regexp="([^,]+),([^,]+),([^,]+),([^,]+),([^,]+)" select="\3" override="true"/>
        <math result="processCount" operand1="${processCount}" operation="+" operand2="1" datatype="int"/>

        <trycatch property="tryName" reference="exception_ref">
          <try>

            <echo>
			================================================================================
			UNDEPLOY COMPOSITE #${processCount}: ${composite.name}
			================================================================================
            </echo>
            <ant antfile="${oracle.home}/bin/ant-sca-deploy.xml" target="undeploy" inheritall="false">
              <property name="user"             value="${server.user}"/>
              <property name="password"         value="${server.password}"/>
              <property name="serverURL"        value="${serverURL}/soa-infra/deployer"/>
              <property name="compositeName"    value="${composite.name}"/>
              <property name="partition"        value="${composite.partition}"/>
              <property name="revision"         value="${composite.revision}"/>
            </ant>
          </try>
          <catch>
            <property name="exception" refid="exception_ref" />
            <property name="message" value="ERROR IN TRYCATCH BLOCK:${line.separator}${exception}" />
            <echo></echo>
            <echo message="${message}" />
            <math result="errorCount" operand1="${errorCount}" operation="+" operand2="1" datatype="int"/>
            <var name="errorProcessNames" value="${errorProcessNames}${line.separator}*     ${composite.name}"/>
          </catch>
        </trycatch>
        <sleep seconds="1" />
      </sequential>
    </for>
    <echo>
		***********************************************************************************
		*
		*  	ANT TARGET NAME		   : undeployComposites
		*  	TOTAL NUMBER OF ERRORS : ${errorCount} of ${processCount} processes
		*  	FAILED PROCESSES	   : ${errorProcessNames}
		*
		***********************************************************************************
    </echo>
  </target>

  <!-- ================================================================================ -->
  <!-- TARGET: listDeployedComposites                                                   -->
  <!-- ================================================================================ -->

  <target name="listDeployedComposites">
  	<trycatch property="tryName" reference="exception_ref">
  	      <try>
		    <ant antfile="${oracle.home}/bin/ant-sca-mgmt.xml" target="listDeployedComposites" inheritall="false">
		      <property name="host" 	value="${server.host}"/>
		      <property name="port" 	value="${server.port}"/>
		      <property name="user" 	value="${server.user}"/>
		      <property name="password"	value="${server.password}"/>
		    </ant>
  	      </try>
	      <catch>
	         <property name="exception" refid="exception_ref" />
	         <property name="message" value="ERROR IN TRYCATCH BLOCK:${line.separator}${exception}" />
	         <echo>=========================</echo>
	         <echo message="${message}" />
	      </catch>
	  </trycatch>    	
  </target>
</project>

Composite Instance States in Oracle SOA 11G Processes

August 3, 2012 Leave a comment

When we are troubleshooting purging soa composites instances or during performance testing of soa composite processes , to understand how many instances are getting Completed , how may instances got faulted ,how how many instances went to NonRecoverable states and etc…. , we can run the below query to get the instance states on SOAINFRA schema.

 

State Description
0 STATE_INITIATED
1 STATE_OPEN_RUNNING
2 STATE_OPEN_SUSPENDED
3 STATE_OPEN_FAULTED
4 STATE_CLOSED_PENDING_CANCEL
5 STATE_CLOSED_COMPLETED
6 STATE_CLOSED_FAULTED
7 STATE_CLOSED_CANCELLED
8 STATE_CLOSED_ABORTED
9 STATE_CLOSED_STALE
10 STATE_CLOSED_ROLLED_BACK

 

-- CUBE_INSTANCE TABLE
SELECT (CASE WHEN STATE=0 THEN 'OPEN AND RUNNING'
             WHEN STATE=1 THEN 'CLOSED AND COMPLETED'
             WHEN STATE=2 THEN 'CLOSED AND FAUTED'
             WHEN STATE=3 THEN 'OPEN AND FAULTED'
             WHEN STATE=4 THEN 'RECOVERY REQUIRED'
             WHEN STATE=34 THEN 'OPEN AND FAULTED'
             WHEN STATE=64 THEN 'CLOSED AND STALE'
             WHEN STATE=32 THEN 'UNKNOWN'
             WHEN STATE=16 THEN 'TERMINATED'
             WHEN STATE=48 THEN 'TERMINATED'
             WHEN STATE=50 THEN 'TERMINATED'
             ELSE STATE || ''
             END) AS STATE, 
             COUNT(*) AS NUM_OF_COMPOSITE_INST FROM DEV_SOAINFRA.CUBE_INSTANCE
                                               WHERE COMPOSITE_NAME='SalesOrder' AND
                                                     CREATION_DATE >= TO_TIMESTAMP('2012-08-02 19:45:00','YYYY-MM-DD HH24:MI:SS') AND 
                                                     CREATION_DATE <= TO_TIMESTAMP('2012-08-02 21:00:00' ,'YYYY-MM-DD HH24:MI:SS') 
                                               GROUP BY STATE;

XPath sample with namespace in Java

August 1, 2012 Leave a comment

Here is the simple example to show the element values of xml file using XPath APIs.

1. Person.xml needs to be parsed using XPath APIs:

<?xml version="1.0" encoding="UTF-8"?>
<pn:Person xmlns:pn="http://www.com.room.xpath.sample">
	<pn:name>
		<pn:firstName>Raja</pn:firstName>
		<pn:middlName>Kumar</pn:middlName>
		<pn:lastName>Robot</pn:lastName>
	</pn:name>
	<pn:title>MR</pn:title>
	<pn:address>
		<pn:streetNo>No.19</pn:streetNo>
		<pn:streetName>Rose St</pn:streetName>
		<pn:city>Sydney</pn:city>
		<pn:state>NSW</pn:state>
		<pn:postalCode>2067</pn:postalCode>
	</pn:address>
</pn:Person>

2. NamespaceContextMap.java

package com.room.xpath.sample;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Iterator;
import java.util.Map;
import java.util.Set;

import javax.xml.XMLConstants;
import javax.xml.namespace.NamespaceContext;

public final class NamespaceContextMap implements
    NamespaceContext {

  private final Map<String, String> prefixMap;
  private final Map<String, Set<String>> nsMap;

  /**
   * Constructor that takes a map of XML prefix-namespaceURI values. A defensive
   * copy is made of the map. An IllegalArgumentException will be thrown if the
   * map attempts to remap the standard prefixes defined in the NamespaceContext
   * contract.
   * 
   * @param prefixMappings
   *          a map of prefix:namespaceURI values
   */
  public NamespaceContextMap(
      Map<String, String> prefixMappings) {
    prefixMap = createPrefixMap(prefixMappings);
    nsMap = createNamespaceMap(prefixMap);
  }

  /**
   * Convenience constructor.
   * 
   * @param mappingPairs
   *          pairs of prefix-namespaceURI values
   */
  public NamespaceContextMap(String... mappingPairs) {
    this(toMap(mappingPairs));
  }

  private static Map<String, String> toMap(
      String... mappingPairs) {
    Map<String, String> prefixMappings = new HashMap<String, String>(
        mappingPairs.length / 2);
    for (int i = 0; i < mappingPairs.length; i++) {
      prefixMappings.put(mappingPairs[i], mappingPairs[++i]);
    }
    return prefixMappings;
  }

  private Map<String, String> createPrefixMap(
      Map<String, String> prefixMappings) {
    Map<String, String> prefixMap = new HashMap<String, String>( prefixMappings);
    addConstant(prefixMap, XMLConstants.XML_NS_PREFIX,XMLConstants.XML_NS_URI);
    addConstant(prefixMap, XMLConstants.XMLNS_ATTRIBUTE,XMLConstants.XMLNS_ATTRIBUTE_NS_URI);
    return Collections.unmodifiableMap(prefixMap);
  }

  private void addConstant(Map<String, String> prefixMap,
      String prefix, String nsURI) {
    String previous = prefixMap.put(prefix, nsURI);
    if (previous != null && !previous.equals(nsURI)) {
      throw new IllegalArgumentException(prefix + " -> "
          + previous + "; see NamespaceContext contract");
    }
  }

  private Map<String, Set<String>> createNamespaceMap(
      Map<String, String> prefixMap) {
    Map<String, Set<String>> nsMap = new HashMap<String, Set<String>>();
    for (Map.Entry<String, String> entry : prefixMap
        .entrySet()) {
      String nsURI = entry.getValue();
      Set<String> prefixes = nsMap.get(nsURI);
      if (prefixes == null) {
        prefixes = new HashSet<String>();
        nsMap.put(nsURI, prefixes);
      }
      prefixes.add(entry.getKey());
    }
    for (Map.Entry<String, Set<String>> entry : nsMap
        .entrySet()) {
      Set<String> readOnly = Collections
          .unmodifiableSet(entry.getValue());
      entry.setValue(readOnly);
    }
    return nsMap;
  }

  @Override
  public String getNamespaceURI(String prefix) {
    checkNotNull(prefix);
    String nsURI = prefixMap.get(prefix);
    return nsURI == null ? XMLConstants.NULL_NS_URI : nsURI;
  }

  @Override
  public String getPrefix(String namespaceURI) {
    checkNotNull(namespaceURI);
    Set<String> set = nsMap.get(namespaceURI);
    return set == null ? null : set.iterator().next();
  }

  @Override
  public Iterator<String> getPrefixes(String namespaceURI) {
    checkNotNull(namespaceURI);
    Set<String> set = nsMap.get(namespaceURI);
    return set.iterator();
  }

  private void checkNotNull(String value) {
    if (value == null) {
      throw new IllegalArgumentException("null");
    }
  }

  /**
   * @return an unmodifiable map of the mappings in the form prefix-namespaceURI
   */
  public Map<String, String> getMap() {
    return prefixMap;
  }

}

3. XPathTest.java

package com.room.xpath.sample;

import java.io.IOException;

import javax.xml.namespace.NamespaceContext;
import javax.xml.parsers.DocumentBuilder;
import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
import javax.xml.xpath.XPath;
import javax.xml.xpath.XPathConstants;
import javax.xml.xpath.XPathExpression;
import javax.xml.xpath.XPathExpressionException;
import javax.xml.xpath.XPathFactory;

import org.w3c.dom.DOMException;
import org.w3c.dom.Document;
import org.w3c.dom.NodeList;
import org.xml.sax.SAXException;

public class XPathTest {
	public static void main(String[] args) {
		try {
			Document doc=getDoc("Person.xml");
			XPath xpath=getXPath();
			xpath.setNamespaceContext(getNamespaceContext());
			XPathExpression expr = xpath.compile("//pn:name/*/text()");
			Object result = expr.evaluate(doc, XPathConstants.NODESET);
			NodeList nodes = (NodeList) result;
			for (int i = 0; i < nodes.getLength(); i++) {
				System.out.println(nodes.item(i).getNodeValue());
			}
		} catch (XPathExpressionException e) {
			e.printStackTrace();
		} catch (DOMException e) {
			e.printStackTrace();
		}
	}

	private static Document getDoc(String fileName) {
		Document doc=null;;
		try {
			DocumentBuilderFactory domFactory = DocumentBuilderFactory.newInstance();
			domFactory.setNamespaceAware(true);
			DocumentBuilder builder = domFactory.newDocumentBuilder();
			doc = builder.parse("Person.xml");
		} catch (ParserConfigurationException e) {
			e.printStackTrace();
		} catch (SAXException e) {
			e.printStackTrace();
		} catch (IOException e) {
			e.printStackTrace();
		}
		return doc;
	}

	private static XPath getXPath() {
		return XPathFactory.newInstance().newXPath();
	}

	private static NamespaceContext getNamespaceContext() {
		NamespaceContext context = new NamespaceContextMap("pn","http://www.com.room.xpath.sample");
		return context;
	}
}