Thursday, November 24, 2011

Oracle SOA Suite – Purging the Xref Data through JAVA API.

Oracle SOA Suite  – Purging the Xref Data through JAVA API.

The Oracle SOA Suite 11g and Oracle SOA Suite 12cprovides the Java API’s that can be used to purge the Xref Data.

The client API provides the Locator class to purge the Xref Data based on the filter.

locator.purgeXRefData(XRefPurgeFilter purgeFilter);

The XRefPurgeFilter class is used to set the filter condition to purge the Xref Data.

XRefPurgeFilter purgeFilter =new XRefPurgeFilter();

purgeFilter.setPurgeXRefTableURI ("oramds:/apps/EAIMetaData/Xref/Test.xref");

Specify the Xref Table for which data needs to be purged. If no column names are provided, all data for that XRef Table would be purged.

purgeFilter.setPurgeXRefTableURI – Can be used only combination with purgeFilter.addColumnToPurge, 

if we are using purgeFilter.setPurgeXRefTableURI with other filter conditions like purgeFilter.setPurgeDataBefore, we would receive the following error.

EJB Exception: ; nested exception is: java.lang.RuntimeException: oracle.tip.xref.exception.RepositoryException: Unable to access Cross Reference Values from Database.The SQL Exception is: "ORA-00933: SQL command not properly ended " Please ensure that the database is accessible. If accessible, please look at the stack trace and fix the issue. If unable to fix contact Oracle Support Fetching Data...

purgeFilter.addColumnToPurge("ColumnA");
Add column names for specified XRef Table whose column data would be purged. 

If we are using purgeFilter.addColumnToPurge with any other filter condition other than purgeFilter.setPurgeXRefTableURI would be ignored.

purgeFilter.setPurgeDataBefore(purgeDataAfter);
Last modified date before which all data in the database would be purged.

purgeFilter.setPurgeAllData(true);
All data in the database would be purged

purgeFilter.setPurgeDataAfter(purgeDataAfter);
Last modified date after which all data in the database would be purged.

The following code snippet will enable you to purge the Xref Data based on the filter condition.

Jar File required - <JDEV_HOME>\soa\modules\oracle.soa.mgmt_11.1.1\soa-infra-mgmt.jar

try
{
Hashtable jndiProps = new Hashtable();
jndiProps.put(Context.PROVIDER_URL,"t3://soahost:soaport");
jndiProps.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
jndiProps.put(Context.SECURITY_PRINCIPAL,"weblogic");
jndiProps.put(Context.SECURITY_CREDENTIALS,"xxxxxx");
jndiProps.put("dedicated.connection","true");
Locator locator = LocatorFactory.createLocator(jndiProps);
java.util.Date purgeData=new Date(2011,11,24);

XRefPurgeFilter purgeFilter =new XRefPurgeFilter();
purgeFilter.setPurgeXRefTableURI("oramds:/apps/EAIMetaData/Xref/Test.xref");
// purgeFilter.addColumnToPurge("ColumnA");
//purgeFilter.setPurgeDataBefore(purgeData);
//purgeFilter.setPurgeDataAfter(purgeData);
// purgeFilter.setPurgeAllData(true);
locator.purgeXRefData(purgeFilter);
}catch(Exception e)
{
e.printStackTrace();
}


Wednesday, November 23, 2011

Business Rule issue while migrating from Oracle SOA Suite 10g to Oracle SOA Suite 11g - Compilation errors with rule facts classes having long qualified package name.

Business Rule issue while migrating from Oracle SOA Suite 10g to Oracle SOA Suite 11g - Compilation errors with rule facts classes having long qualified package name.

If we had used the long qualified package name with rule facts classes (mainly with XML facts)e.g. “com.xxxxxxx.ns._2007._01._25.gcap.eai.ordermanagement” in 10g Business rule ,we will be receiving the below error during the compilation of the composite with the migrated rule in 11g.



[scac] error: location {/ns:composite/ns:import[@location='file:/D:/Albin/EAI/DevCodeBase/11g_Migration/CRM_EAI_code_deploy/code/OrderRequestRule/OrderRequestRule/OrderLineRequestDictionary141008_DecisionService_1.wsdl']}: Load of wsdl "OrderLineRequestDictionary141008_DecisionService_1.wsdl with Message part element undefined in wsdl [file:/D:/Albin/EAI/DevCodeBase/11g_Migration/CRM_EAI_code_deploy/code/OrderRequestRule/OrderRequestRule/OrderLineRequestDictionary141008_DecisionService_1.wsdl] part name = payload type = {http://xmlns.oracle.com/OrderLineRequestDictionary141008/OrderLineRequestDictionary141008_DecisionService_1}callFunctionStatelessDecision" failed
[scac] error: location {OrderLineRequestDictionary141008}: Rule Dictionary OrderLineRequestDictionary141008 is invalid.
[scac] error: location {OrderLineRequestDictionary141008}: Function OrderLineRequestDictionary141008.Version1_1.OrderLineRequestDictionary141008.OrderLineRequestDictionary141008_DecisionService_1 does not exist in rule dictionary

The rule facts need to be recreated with the shorter package name to overcome this compilation error.

The below are the steps to recreate the rule facts from XSD:

1. Remove all the XML facts - Open the rule dictionary and remove all the facts available.




Sunday, November 20, 2011

Migrating the WEBDAV Business Rule Repository from Oracle SOA Suite 10g to Oracle SOA Suite 11g format and exposing the rules as a webservice.


Migrating the WEBDAV Business Rule Repository from Oracle SOA Suite 10g to Oracle SOA Suite 11g format and exposing the rules as a webservice.

If we had used the Business Rule in 10g the same should be migrated to 11g.The below are the steps to migrate the sample webdav rule repository from 10g to 11g and to expose the rule dictionary as a service.
  1. Create a folder Rules with child folders “jaxboutput” and “xsd”.
  1. Copy the xsd files used in 10g to build the Input/output of rule to xsd folder.
  1. Crete a java file “RuleMigrator.java” with the below contents.
import java.io.PrintWriter;
import java.util.ArrayList;
import oracle.rules.tools.migrator.MigrateRuleRepository;
public class RuleMigrator {
public RuleMigrator() {
super();
}
public static void migrateRule() throws Exception{
String parent_output_dir=System.getenv("rule.output.path");
MigrateRuleRepository conv = new MigrateRuleRepository();
// Set the output buffer
conv.setOutLog(new PrintWriter(System.out));
// Set input properties (SDK format)
conv.setOriginLocation(System.getenv("rule.repository.location"));
conv.setXSDOutputDir(parent_output_dir+"\\jaxboutput");
conv.setOriginType(MigrateRuleRepository.WEBDAV_REPO);
conv.setOriginUserid(System.getenv("rule.repository.username"));
conv.setOriginPassword(System.getenv("rule.repository.password"));
conv.setOriginDictionaryName(MigrateRuleRepository.MIGRATE_ALL);
conv.setOriginVersionName(MigrateRuleRepository.MIGRATE_ALL);
conv.setLogWithStackTrace(true);
conv.setXSDLocation(parent_output_dir+"\\xsd");
// Set output properties
conv.setDestinationLocation(current_dir+"\\Rules");
System.out.println("Before calling migrate");
conv.migrate();
String results = conv.getTotalStats();
System.out.print(results);
}
public static void main(String[] args) {
try
{
migrateRule();
}catch(Exception e) {
e.printStackTrace();
}
}
}



Oracle SOA Suite - Configure transaction timeout for BPEL.


Oracle SOA Suite - Configure transaction timeout for BPEL:

The timeouts should be configured based on the below condition

SyncMaxWaitTime < BPEL EJB's transaction timeout < Global Transaction Timeout

Setting the SyncMaxWaitTime : 

 This is the maximum time a synchronous BPEL process waits before it times out to get the response from another BPEL or a web service.
  •  Login to EM console
  • Expand SOA and right click on "soa-infra"
  • From context menu, select SOA Administration –> BPEL properties
  • Click on "More BPEL Configuration properties"
  • Enter the appropriate value for the SyncMaxWaitTime

Setting the global transaction timeout at Weblogic Domain Level:

This property controls the transaction timeout seconds for active transactions. If the transaction is still in the "active" state after this time, it is automatically rolled back.
  • Log into Oracle Weblogic Administration Console.
  • Click Services -> JTA.
  • Change the value of Timeout Seconds to the required value (the default is 30).
  • Click Save.
  • Restart Oracle Weblogic Server.

Overriding the transaction timeout setting for BPEL EJB's:

The timeout properties for the EJB's control the particular timeout setting for the SOA application, overriding the global setting specified by the JTA timeout
  • Log into Oracle Weblogic Administration Console.
  • Click Deployments.
  • Expand soa-infra -> EJBs.
  • Click on the configuration tab for the timeout setting for each of EJB’s listed below and the change the time out values as required.
  • Following EJBs need to be updated:
BPELActivityManagerBean
BPELDeliveryBean
BPELDispatcherBean
BPELEngineBean
BPELFinderBean
BPELInstanceManagerBean
BPELProcessManagerBean
BPELSensorValuesBean
BPELServerManagerBean
  • Click Save.
  • Restart Oracle Weblogic Server.


Thursday, November 17, 2011

Oracle SOA Suite - Abort the running composite instances through JAVA API


Abort the running Oracle SOA Suite composite instances through JAVA API:

Sometimes we may required to abort the running composite instances, the JAVA APIs can be used to abort the running instances of a composite. To abort the instance, we have to identify the running composite instances based on the instance state and the same can be aborted by using the abort method available in the CompositeInstance class.

The below code snippet will help us to abort the running instance of the particular composite, the filter condition can be changed accordingly to abort the running composite instances with different matching criteria.

try
{
String compositeName="GetDomainID";
Hashtable jndiProps = new Hashtable();
jndiProps.put(Context.PROVIDER_URL,"t3://soahost:soaport");
jndiProps.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
jndiProps.put(Context.SECURITY_PRINCIPAL,"weblogic");
jndiProps.put(Context.SECURITY_CREDENTIALS,"xxxxx");
jndiProps.put("dedicated.connection","true");
Locator locator = LocatorFactory.createLocator(jndiProps);
CompositeInstanceFilter filter =new CompositeInstanceFilter();
filter.setState(CompositeInstance.STATE_RUNNING);
filter.setCompositeName(compositeName);
// filter.setId("670002");
List<CompositeInstance> compositeInstances = locator.getCompositeInstances(filter);
for(int i=0;i<compositeInstances.size();i++)
((CompositeInstance)compositeInstances.get(i)).abort();
}catch(Exception e)
{
e.printStackTrace();
}

Execution of this code will abort all the running instances of a specified composite.

Jar files - 

$Middleware_Home\Oracle_Home\oracle_common\modules\internal\features\jrf_wlsFmw_oracle.jrf.wls.classpath.jar
$Middleware_Home\Oracle_Home\soa\soa\modules\oracle.soa.fabric_11.1.1\oracle.soa.fabric.jar
$Middleware_Home\Oracle_Home\wlserver\server\lib\weblogic.jar