Wednesday, August 10, 2016

Abort RUNNING Instances of SOA Composite using java API



Sometimes we may need to abort RUNNING instances of a SOA composite or abort single long running instance. It’s pretty easy in em console but sometimes it won’t work  so I came up with below java program which will help you to abort instances. You can change program according to your need.

import java.util.Hashtable;
import java.util.List;

import javax.naming.Context;

import oracle.soa.management.facade.Component;
import oracle.soa.management.facade.ComponentInstance;
import oracle.soa.management.facade.Composite;
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 oracle.soa.management.facade.CompositeInstance;
import oracle.soa.management.CompositeDN;

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

    public void abortRunningComposite() {
        try {

            Locator locator = null;
            Hashtable jndiProps = new Hashtable();
            //Connection Details to Connect to Server
            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");

            //Connect to SOA Server
            locator = LocatorFactory.createLocator(jndiProps);
            System.out.println("Connected to SOA Server.");

            CompositeInstanceFilter filter = new CompositeInstanceFilter();
            String compositeName="YourCompositeName"; 
            //filter.setId("1238098"); Use this incase if you want to delete specific instance id 
            filter.setState(CompositeInstance.STATE_RUNNING);
            filter.setCompositeName(compositeName); 
            List<CompositeInstance> compositeInstances = locator.getCompositeInstances(filter);
            for(int i=0;i<compositeInstances.size();i++)
            ((CompositeInstance)compositeInstances.get(i)).abort(); 
            }catch(Exception e) 
            { 
            e.printStackTrace(); 
            }
            }
    public static void main(String[] args) {
        abortComposite abortcomposite = new abortComposite();
        abortcomposite.abortRunningComposite();
    }
}



Steps:-
Set Classpath
export CLASSPATH=$CLASSPATH:$ORACLE_FMW_HOME/oracle_common/soa/modules/oracle.soa.mgmt_11.1.1/soa-infra-mgmt.jar:$ORACLE_FMW_HOME/oracle_common/modules/oracle.fabriccommon_11.1.1/fabric-common.jar:$ORACLE_FMW_HOME/wlserver_10.3/server/lib/weblogic.jar:$ORACLE_FMW_HOME/oracle_common/modules/oracle.jrf_11.1.1/jrf-api.jar

Sunday, November 24, 2013

Meta Data Store(MDS) Setup in SOA 11g

SOA Suite 11g has a provision for sharing SOA artifacts through MDS – Meta Data Store. This facilitates greater re-use of SOA artifacts such as XML Schemas, EBMs, WSDLs, Fault Policies, Rule repositories and Service Data Objects (SDOs) . You can configure MDS as  file-based or database-based. 

MDS is created under JDEV_HOME/integration/seed directory. Default folder “soa” is used to store common system soa artifacts. All custom artifacts are supposed to be stored under a folder called “apps”, since this folder already exists in server.

Create directory structure under apps folder. In my case, I’ve created folder structure JDEV_HOME/integration/seed/apps/myproject/xsd/ to store XML schema files. This ideally should match your schema structure.

1. First you go to your local 11g Jdeveloper installation folder. In my case it is C:\OracleFMW\Middleware\jdeveloper\integration folder .You can see seed folder , If not create a seed folder.
2. Now create folder with name apps under seed.
3. Under apps you can create your folder structure to place all your XSD, WSDL files like   apps/xsd/employee.xsd  etc.
4. Create MDS connection in jdeveloper as below.
New -> Connections -> SOA-MDS Connection




5. The SOA-MDS connection can be created in two ways. One is File Based MDS and other is Data Based MDS.

6. In Create SOA_MDS Connection window, select File Based MDS as Connection  Type for file based MDS connection, we will point to the local folder in our system   where all the WSDL and XSD files are placed as shown below. So when we use the wsdl and xsd files in the  project, they will be referred from the local system.





7.Click OK. Now the File Based MDS connection is created.

8. Lets see how to create DB based MDS connection. In Create SOA_MDS Connection window, select DB Based MDS as Connection Type for file based MDS connection.


9. For DB Based MDS connection, we should have created all the schema for the weblogic in the database by running the Repository Creation Utility (RCU) wizard. After RCU execution, the DEV_MDS schema will get created in the database. We need to use the DEV_MDS schema connection and soa-infra as MDS Partition while creating the DB Based MDS connection as shown in the above screen shot.( Get in touch with your DBA for MDS schema credentials)

10. Click OK. Now the DB Based MDS connection is created.

Deploy MDS repository to Weblogic Server
First, we need to create JAR file bundle to include schemas,WSDL's  we need. Then we need to include this jar file into a SOA bundle that can be deployed to the SOA Server.

In JDeveloper Create Generic Application - MediatorMetaData

Create a project – MediatorLib
Right click on MediatorLib and select New –> Deployment Profile –> JAR File


Enter mediatorlib as the deployment profile name.

In the JAR deployment properties dialog, click on Contributors, click on Add button and select apps directory from your JDeveloper seed location – JDEV_HOME/integration/seed/apps  As for below screenshots


Click on OK. This completes creation of JAR file. We now need to create an application deployment profile to install these schemas in SOA Server.

Right click on MediatorMetaData application and select Deploy –> New Deployment Profile. Select “SOA Bundle” as Profile type.

Enter mediatorlib for Deployment Profile Name. From the properties dialog, open Dependencies and select mediatorlib.


To deploy MediatorLib to SOA Server, right click on MediatorMetaData and select Deploy –> mediatorlib.

How to refer MDS Files in the Project
In JDeveloper, under Application resources expand Descriptors/ADF META-INF and open adf-config.xml.


Friday, February 24, 2012

Configure Multiple Email accounts in SOA 11g.

In SOA 10g we can configure multiple email accounts under ns_emails.xml and its simple.


But in 11g its completely different, for every email account you need deploy email driver.here are the complete steps you need to follow to achieve this.


1. Edit the deployment plan for email driver application (for example: ORACLE_SOA_HOME/communications/plans/usermessagingdriver-email_Plan.xml)
  • Backup the original plan (ORACLE_SOA_HOME/communications/plans/usermessagingdriver-email_Plan.xml)
  • Copy the plan to a location of your choice (to the same directory or any other directory), rename it to usermessagingdriver-email_Plan2.xml
  • Open usermessagingdriver-email_Plan2.xml in any text editor, search an replace @DriverDeploymentName@ with whichever name you want to use (ensure you replace all instances of the name).
  • Search and replace @DriverShortName@ with any name you like(ensure you replace all instances of the name).
          e.g.
          REPLACE                                           WITH
          @DriverDeploymentName@    ->        usermessagingdriver-email2
          @DriverShortName@              ->        email2
    @RunAsPrincipalName@       ->        OracleSystemUser
  • Save this file.
2. Start Oracle Enterprise Manager Fusion Middleware Control. Navigate to WebLogic Domain > >
3. Right click on , then select Application Deployment > Deploy...
4. The Deploy Java EE Application Window appears, in the step1 of 4, enter the location of the .ear file and Deployment Plan
e.g.
    EAR location: ORACLE_SOA_HOME/communications/applications/sdpmessagingdriver-email.ear
    Deployment Plan: ORACLE_SOA_HOME/communications/plans/usermessagingdriver-email_Plan2.xml



5. In Select Target, select , click Next.

6. In Step 3 of 4, Application Attributes page,



  • Enter an application name. The application name must exactly match the string used in the Deployment Plan. If it does not, the deployment and activation fails.
  • Modify the context root for email-mbeanlifecycle.war web module, the default is sdpmessagingdriver/email-mbeanlifecycle. You have to change it to a different value as this one is already used by the existing email driver application.
          e.g.
          Application Name: sdpmessagingdriver-email2
          Context root for email-mbeanlifecycle.war : sdpmessagingdriver2/email-mbeanlifecycle


7. Click Next, then Deploy


Restart SOA server and open em console, you find new email driver that you deployed under User messaging service. 
select usermessagingdriver-email2 driver properties ,configure your email account.


Tuesday, October 11, 2011

Import Client Certificates in SOA 11g

This Article will teach you how to Import Client Certificates in SOA 11g 


Solution 1:


Steps:   
  • Download client certificate from Mozilla or IE,name it as gmail-smtp.cer   
  • Open command prompt and Import this Certificate into your JDK certs file using keytool
keytool -import  -file E:\gmailCert\gmail-smtp.cer -alias RootCA -keystore C:\Oracle\Middleware\jdk160_24\jre\lib\security\cacerts -storepass changeit

  • Create new keystore  and name it myykeystore.jks using blow command 
keytool -genkey -keystore C:\Oracle\Middleware\wlserver_10.3\server\lib\mykeystore.jks -storepass welcome1

  • Import your certificate into mykeystore.jks keystore.
keytool -import  -file E:\gmailCert\gmail-smtp.cer -alias RootCA -keystore C:\Oracle\Middleware\wlserver_10.3\server\lib\mykeystore.jks -storepass welcome1

  • Edit C:\Oracle\Middleware\user_projects\domains\base_domain\bin\setDomainEnv.cmd.search for -Djavax.net.ssl.trustStore text in the file and replace with
-Djavax.net.ssl.trustStore=${WL_HOME}/server/lib/mykeystore.jks   
-Djavax.net.ssl.trustStorePassword=welcome1

  •  Open Admin Console and modify the keystore for SOA server.Click on Change button and select the custom Identity and java standard trust  from dropdown.
Custom Identity Keystore:C:\Oracle\Middleware\wlserver_10.3\server\lib\mykeystore.jks
Custom Identity Keystore Type: jks
Custom Identity Keystore Passphrase: welcome1
Confirm Custom Identity Keystore Passphrase: welcome1

Restart SOA server and then test.


Solution 2



  •     Obtain security certificate from SFDC to connect to SFDC services (e.g. sfdc-client.cert).
  •    Import certificate obtained from SFDC into keystore
  •       /xgsoadv4a/oracle/fmw/java/bin/keytool -import -alias proxy.salesforce.com -keystore     SFDCKeyStore.jks -file /home/soaadmin/temp/sfdc-client.cert
  •   Remove the following entry from domain's setDomainEnv.sh (<domain_home>/bin/setDomainEnv.sh) -  
  •           -Djavax.net.ssl.trustStore=${WL_HOME}/server/lib/DemoTrust.jks .
  •  Login to the Fusion Middleware Control console (i.e. "http://WLserver:port/em") . Navigate to Farm_<domain>/SOA/soa-infra". Right-click on "soa-infra" on the left pane. Select "SOA Administration --> Common Properties", click the hyperlink at the bottom for "More SOA Infra Advanced Configuration Properties".
  •  Find the entry for KeystoreLocation - and provide the path to the keystore that contains CA Certificates. Click on Apply.



6.       Add credential entry to allow BPEL to open the keystore file. Navigate to "WebLogic Domain/<domain name>". From pulldown menu, select "Security->Credentials". Add a new map called "iClickSFDC" and add two new keys inside that map (default password is changeit):
Key Name
Type
User Name
Password
KeyPassword
password
KeyPassword
<password>
KeystorePassword
password
KeystorePassword
<password>




7.       Restart webLogic domain servers.



Tuesday, March 15, 2011

How do you configure transaction timeout for BPEL on SOA 11g?

As a general rule, you should keep the following relation between the timeout parameters:

syncMaxWaitTime < BPEL EJB's transaction timeout < Global Transaction Timeout
Note: This recommendation are ONLY applicable to Sync Processes. Additionally the default Timeout setting that comes with SOA 11g installation does not comply with this rule. You might need to adjust the setting according to your particular business needs.


1. Setting syncMaxWaitTime:

This property controls the maximum time the process result receiver will wait for a result before returning for Sync processes.

For SOA 11g R1 PS1 (11.1.1.4 and later):
* Login into EM
* Expand SOA and right click on "soa-infra" and select: SOA Administration -> BPEL Properties
* Click on "More BPEL Configuration Properties..." link
* Locate syncMaxWaitTime and change it.


2. Setting the transaction timeout 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 (See step 3).

* Log into Oracle WebLogic Administration Console.

Stop SOA Managed Server
* Click Deployments.

* Expand soa-infra -> EJBs.
* Following EJBs need to be updated:
BPELActivityManagerBean
BPELDeliveryBean
BPELDispatcherBean
BPELEngineBean
BPELFinderBean
BPELInstanceManagerBean
BPELProcessManagerBean
BPELSensorValuesBean
BPELServerManagerBean
* You can check in the config tab for the timeout setting in the BPEL* EJBs.
* Click Save.
* Restart Oracle WebLogic Server.

3. 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 (the default is 30).
   * Click Save.
   * Restart Oracle WebLogic Server.



More information available at:



Note: For receive/invoke timeout introduced for Async Processes with PS3, refer:
http://download.oracle.com/docs/cd/E17904_01/integration.1111/e10224/bp_events.htm#insertedID0

How to set delay between JMS/AQ Quque Messages in soa11g



After reading your issue, description I would like to suggest the below solution:


There is an activation agent which can be used to control the speed at which the adapter posts messages to BPEL 


in 11G the setting would be configured as a binding property in the composite.xml the corresponding (inbound) <service>, e.g. 


<service name="Inbound">
<interface.wsdl interface="http://xmlns.oracle.com/pcbpel/demo1#wsdl.interface(SampleInbound_PortType)"/>
<binding.jca config="Dequeue_jms.jca">
<property name="minimumDelayBetweenMessages">1000</property> ------ this is the property that is being implemented.
</binding.jca>
</service> 


This setting ensures that there at least will be 1000 milliseconds delay between the two consecutive messages being posted to the BPEL process.


Note: this setting pertains only to BPEL, and only to one adapter polling thread. If multiple adapter polling threads (e.g. multiple JMS dequeuer threads) have been configured, this setting will control the speed of each thread, not the combined speed.


By implementing the above mentioned solution, I would like to highlight one point though, you need to keep in mind that the delay will happen all the time regardless of heavy or light load. 

How to make your File Adapter pick only one file at a time from a location

In SOA 11g, you use File adapter to read files from the given location.
With this read operation it picks all the files at time.

You want to configure File Adapters that it should pick one file at time from the given location with given polling interval.

Solution :

You set the "SingleThreadModel" and "MaxRaiseSize" properties for your file adapter.
Edit the adapter's jca file and add the following properties:

property name="SingleThreadModel" value="true"
property name="MaxRaiseSize" value="1"

You can set these properties also through jdeveloper, by opening composite.xml, selecting the adapter and then changing the properties through the properties panel.