Monday, December 17, 2012

Updating the BPEL Component preference value from JAVA – Oracle SOA 11g

Written By Archit Bhardwaj

Sometimes we may need to update the preference value for the BPEL component, the below java code will help us to update the preference value.

This update is not a cluster-aware,remember that you must repeat the same process for each managed server of your environment.
Before executing the code change the mbeanName accordingly.
   String mBeanName ="*:*,j2eeType=SCAComposite.SCAComponent,revision=*,SCAComposite=\"Preference\",name=Preference";




import java.util.*;
import javax.management.*;
import javax.management.openmbean.CompositeDataSupport;
import javax.management.remote.*;
import javax.naming.Context;

public class UpdatePreferenceValue {  

    public static MBeanServerConnection getMbeanServerConnection(String host,
                                                                 int port,
                                                                 String userName,
                                                                 String password) throws Exception {
        String jndiroot = "/jndi/";
        MBeanServerConnection m_connection = null;
        try {
            Hashtable jndiProps = new Hashtable();
            jndiProps.put(Context.SECURITY_PRINCIPAL, userName);
            jndiProps.put(Context.SECURITY_CREDENTIALS, password);
            jndiProps.put(JMXConnectorFactory.PROTOCOL_PROVIDER_PACKAGES,"weblogic.management.remote");

            JMXServiceURL serviceURL =new JMXServiceURL("t3", host, port, jndiroot +"weblogic.management.mbeanservers.runtime");
            JMXConnector m_connector =JMXConnectorFactory.newJMXConnector(serviceURL, jndiProps);
            m_connector.connect();
            m_connection = m_connector.getMBeanServerConnection();

        } catch (Exception e) {

            e.printStackTrace();
        }
        return m_connection;
    }


    private static CompositeDataSupport UpdatePreferenceData(CompositeDataSupport cds,String[] keys,String[] newValues) throws Exception {
        Map<String, Object> items =new HashMap<String, Object>(cds.getCompositeType().keySet().size());

        for (String key : cds.getCompositeType().keySet()) {
            boolean matched = false;
            int i = 0;

            for (; i < keys.length; i++) {
                String searchKey = keys[i];

                if (searchKey.equalsIgnoreCase(key)) {
                    items.put(key, newValues[i]);
                    matched = true;
                    break;
                }
            }       

            if (!matched) {             
                    items.put(key, cds.get(key));
            }
         
        }
    

        return new CompositeDataSupport(cds.getCompositeType(), items);
    }
  
    public static void updatePreference(String host,String port,String userName,String password, String  preferenceName,String value) {
 
        String mBeanName ="*:*,j2eeType=SCAComposite.SCAComponent,revision=*,SCAComposite=\"Preference\",name=Preference";

        MBeanServerConnection mbsc;
        try {
            mbsc =getMbeanServerConnection(host, Integer.parseInt(port),userName,password);
            Set<ObjectName> mbeans=mbsc.queryNames(new ObjectName(mBeanName), null);
            ObjectName mbean=(ObjectName)mbeans.iterator().next();
           javax.management.openmbean.CompositeData[] properties =
               (javax.management.openmbean.CompositeData[])mbsc.getAttribute(mbean,"Properties");
         
            for (int i = 0; i < properties.length; i++) {
                CompositeDataSupport cds = (CompositeDataSupport)properties[i];

                if (preferenceName.equalsIgnoreCase((String)cds.get("name"))) {

                    properties[i] =UpdatePreferenceData((CompositeDataSupport)properties[i],new String[] { "value" },new String[] { value });
                    mbsc.setAttribute(mbean,new Attribute("Properties", properties));
                }
            }

        } catch (Exception e) {
            e.printStackTrace();
        }
    }
   
    public static void main(String[] args) {
        updatePreference("localhost", "8000","weblogic", "password","preference.password","password");
        }
    }

Add the weblogic.jar file to the class.

########

Migrating the Metadata from SOA 10g to 11g and sharing the common artifacts to MDS Repository.

Migrating the Metadata from SOA 10g to 11g and sharing the common artifacts to Repository:
If we use the Domain Value Maps (DVMs) or Cross References in Oracle BPEL Process Manager 10g or Oracle Enterprise Service Bus 10g project, the Xpath functions used to access the domain value maps or cross references will be upgraded automatically when the projects are upgraded in Oracle JDeveloper 11g.
However, a manual upgrade task has to be performed to upgrade the domain value maps and cross references that are saved in the Oracle Enterprise Service Bus repository. Also, if we use the common schemas or WSDLs in 10g project the same should be migrated to MDS repository; in 11g all the common artifacts will be stored in MDS repository.
There is a lot of information for the same topic but thought of sharing my experience.
Below are the steps for migrating the DVMs and XREFs to 11g and also to create the project that will have all the common artifacts like DVM, XREF, WSDL and SCHEMAs that can be stored to MDS repository.
Export the DVM and XREF metadata from 10g server: (Steps should be executed on 10 g server)
  1. Log on to your Oracle SOA Suite 10g server.
  2. cd $ORACLE_HOME/integration/esb/bin
  3. Set the environment - ./ esbsetenv.sh
  4. Run the export.sh script to export the entire ESB metadata - ./export.sh metadata10g.zip.
  5. Copy the metadata10g.zip file from $ORACLE_HOME\integration\esb\bin to the Oracle SOA 11g server.
Convert the ZIP file to an Oracle SOA Suite 11g archive file (Steps should be executed on 11g server) :
  1. Log on to your Oracle SOA 11g server
  2. Set your environment:
export DomainHome=<<Weblogic DomainHome>>
export OracleHome=<<OracleHome>>
cd $DomainHome/bin
. setDomainEnv.sh
  1. Execute the below comments to convert the 10g metadata to 11g format.
cd $OracleHome/bin
ant -f ant-sca-upgrade.xml upgrade-xrefdvm -Dsource=<<Path to metadata10g.zip>> -Dtarget= <<Target path>>
  1. Copy the archive sca_XrefDvmFiles10g_rev1.0.jar generated in target path to local machine.
Create the Metadata project:
  • Create a new Generic Application (e.g. MetaDataApp) in JDeveloper 11g.
  • Click “Next” and Give a Project Name e.g. Metadata.
  • From the Oracle JDeveloper 11g “File” menu, select “Import”, then “SOA Archive into SOA Project”. In the Import Composite Archive Dialog Box, click Browse and locate the sca_XrefDvmFiles10g_rev1.0.jar file that you created previously.
  • Make sure that the Project Name and Composite Name in the Create SOA Project from SOA Archive dialog box and Import Composite Archive Dialog Box have the same name.
  • Click Finish to create the new SOA project. The new project consists of an empty composite, along with the upgraded Xref and DVM files.
  • Crete new folders with the name Xref, dvm, faultpolicy, schemas and WSDL under SOAContent of the project folder based on the different type of artifacts needs to be stored in MDS.



  • Group the dvm’s to dvm folder and the xref’s to Xref folder. By default all content is grouped in the project folder in the file system.


  • Copy the common schemas from 10g to the schemas folder of Metadata project.


  • Copy the common WSDL’s from 10g to the WSDL folder of Metadata project.



  • Copy the fault Policy and fault binding files to faultpolices folder of MeatDataProject.

  • Remove the folders those are not required like xsl, xsd, classes and testsuites from the Metadata project.


Now the metadata application is ready with all the common artifacts, create a metadata archive file and deploy the project to the server, the metadata can be referred in the Composite with the help of oramds protocol.

########

Oracle SOA 11g - 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.

########

Oracle SOA Suite 11g – Advanced Configurations for Database Adapter.

This blog give the insight on the new features in Database Adapter configuration in SOA 11g.

Query by Example:
A new Operation type 'Query by Example' has been introduced in Database Adapter Configuration. Query By Example does not require a selection criteria to be specified at design time like SELECT Operation. A selection criteria is inferred from an exemplary input XML record for each invoke. Use queryByExample when you do not want to create a query using the visual query builder and want the flexibility of allowing the input record to share the same XML schema as the output records. The queryByExample operation is will take little more time compared to SELECT operation because a new SELECT must be prepared for each execution.
Doing Synchronous Post to BPEL (Allow In-Order Delivery):
In this feature, the entire invocation is in a single thread and global transaction. By default, initiation is asynchronous and the BPEL process is invoked in a separate global transaction. With Oracle Mediator, it is generally a synchronous invoke so this is only specific to an Oracle BPEL process.
Advanced Options:
A new screen in Adapter configuration wizard for advanced options is added. This screen shows different options based on the type of operation selected. The below are the some of the advanced configurations.
Auto-Retries:
We can set options like no. of retry attempts, interval between retries back-off factor and max interval values.
JDBC Options: This includes options like Query timeout value to specify the timeout for query execution.
Interaction Options: This includes various interaction options. Get Active UnitOfWork ( advanced setting that forces all invoke activities in the same global transaction to use the same SQL connection if going to the same database), Detect Omissions (allows the MERGE and INSERT operations to ignore empty or missing XML elements in the input payload), Optimize Merge (should always be set to true, as it is a general enhancement to MERGE performance)
Native Sequencing (Oracle only):
Allows specifying that the primary key will be assigned from a sequence on any insert.
Polling Options:
For Polling Options the below are the two new configuration parameters added.
Enable Streaming: This option is used to enable support to stream the payload. The payload is streamed to a database instead of getting manipulated in SOA run time as in a memory DOM. This feature is used while handling large payloads.
Schema Validation: When set to true, all XML files produced by the polling Oracle Database Adapter (for Receive activities) is validated against the XSD file. On failure, the XML record is rejected but still marked as processed by the Oracle Database Adapter.
More detailed SQL queries display with sections for Polling SQL and After Read SQL

########

Oracle SOA 11g - Changing the service endpoint URL dynamically through EM console

Sometimes we may need to change the default endpoint location of the service through the EM console.

The below steps help us to change the endpoint URL’s of the references through the EM console.
  • In EM console click on the Composite
  • Scroll down to Service and References section

  • Click on Reference link and properties tab
  • Change Endpoint Address to the desired location and click apply

The new request will be send to the new endpoint location configured through the EM console.
The new endpoint configuration can be removed to send the request to the default endpoint location configured in the WSDL.

########

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

We used to get the following exception in the 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 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.

Follow the below 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


  • Click on Module-FMWDFW


  • Click on Watches and Notifications


  • Click on Deadlock


  • Uncheck the below highlighted (Enable Watch)

  • Save the changes and continue the same for remaining 2 components as well. 
               StuckThread  and UncheckedException 
  • Save the changes.
  • Restart all servers (admin and managed)
The default message size of all the servers can also be increased. The configure can be changed in the protocol section of the server configuration from the weblogic console as shown below



This stabilized the connectivity issue between the managed servers and the Admin Server.

########

Cluster Constraint for the deployment in weblogic server

luster constraint specifies that deployments targeted to a cluster succeed only if all servers in the cluster are running.

When this option is enabled, WebLogic Server enforces a strict two-phase deployment policy for all Managed Servers in a domain—ensuring that application deployment to a cluster succeeds only if all Managed Servers in the cluster are reachable and can deploy the application. If any server instance in the cluster is unreachable, the application is not deployed to any of the Managed Servers.

If you do not enable this option, WebLogic Server allows deployment to a partial cluster. When the unreachable Managed Server becomes available, deployment to that server instance will be initiated.

By default, cluster constraints are disabled and deployment is attempted only on the servers that are reachable at the time of deployment from the Administration Server.

To Enable Cluster Constraint:


  • Login to Weblogic Admin Console
  • Click on the domain name
  • Select the Check box against “Enable Cluster Constraint”

########

Sunday, December 16, 2012

Oracle SOA 11g - Important SQL queries to get the details about composites from SOAINFRA schema

Query to find the execution time of the BPEL instances:-
SELECT * FROM (SELECT COMPOSITE_NAME COMPOSITENAME,A.CMPST_ID COMPOSITE_INSTANCE_ID,creation_date BEGIN_TIME,modify_date END_TIME ,(extract(day from modify_date - creation_date)*86400+ extract(hour from modify_date - creation_date)*3600+ extract(minute from modify_date - creation_date)*60+ extract(second from modify_date - creation_date)) duration_in_second,A.* FROM cube_instance A where state = 5 and CREATION_date BETWEEN TO_DATE('19/01/2012 00:58:00','dd/mm/yyyy HH24:MI:SS')AND TO_DATE('19/01/2012 23:59:59','dd/mm/yyyy HH24:MI:SS') AND COMPOSITE_NAME IN (<<Composite Name>>)) ORDER BY COMPOSITE_NAME,duration_in_second DESC
Query to find the execution time of the Mediator instances:-
SELECT * FROM (SELECT COMPONENT_NAME COMPONENTNAME,A.COMPOSITE_INSTANCE_ID INSTANCE_ID,created_time BEGIN_TIME,updated_time END_TIME ,(extract(day from updated_time - created_time)*86400+ extract(hour from updated_time - created_time)*3600+ extract(minute from updated_time - created_time)*60+ extract(second from updated_time - created_time)) duration_in_second,A.* FROM mediator_instance A where CREATED_TIME BETWEEN TO_DATE('30/01/2012 00:58:00','dd/mm/yyyy HH24:MI:SS')AND TO_DATE('31/01/2012 23:59:59','dd/mm/yyyy HH24:MI:SS') AND A.COMPONENT_NAME like '%<<Meditor Composite Name>>%') ORDER BY COMPONENT_NAME,duration_in_second DESC
Query to find the count of Composite instances created on particular time:-
BPEL instances:-
select * from (select count(COMPONENT_NAME) count,COMPONENT_NAME from CUBE_INSTANCE where CREATION_DATE BETWEEN TO_DATE('30/01/2012 12:58:00','dd/mm/yyyy HH24:MI:SS')AND TO_DATE('31/01/2012 23:00:00','dd/mm/yyyy HH24:MI:SS') /*and component_state<5*/ group by COMPONENT_NAME ) order by count desc
Mediator Instances:-
select * from (select count(COMPONENT_NAME) count,COMPONENT_NAME from MEDIATOR_INSTANCE where CREATED_TIME BETWEEN TO_DATE('30/01/2012 12:58:00','dd/mm/yyyy HH24:MI:SS')AND TO_DATE('31/01/2012 23:00:00','dd/mm/yyyy HH24:MI:SS') group by COMPONENT_NAME ) order by count desc
Getting the count of instances in different state for the BPEL Components:-
select composite_name,count(*),DECODE(cube_instance.STATE,

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','unknown') state from CUBE_INSTANCE group by state,composite_name order by composite_name;
Getting the count of instances in different state for the Mediator Components:-
select COMPONENT_NAME,count(*),DECODE(mediator_instance.COMPONENT_STATE,

0, 'STATE_CLOSED_COMPLETED',

2, 'STATE_OPEN_FAULTED',

4,'STATE_RECOVERY_REQUIRED',

8, 'STATE_OPEN_RUNNING',

16, 'STATE_CLOSED_STALE',

48, 'STATE_TERMINATED',

50, 'STATE_TERMINATED','unknown') STATE from mediator_instance group by component_state,COMPONENT_NAME order by COMPONENT_NAME;
Querying the call back message status from dlv_message table:-
Error to deliver the call back to the receive activity:-
select count(*) from dlv_message where dlv_type = 2 and state=1
Callback arrived but did not get resolved:-
select count(*) from dlv_message where dlv_type = 2 and state=0
Callback successfully delivered to receive:-
select count(*) from dlv_message where dlv_type = 2 and state=2

Querying recoverable invoke messages :-
select * from dlv_message where dlv_type = 1 and state = 0;

To check for rejected messages for a specific composite:
select count(*) from rejected_message where composite_dn like '%<<Composite Name>>%';

########

Oracle SOA 11g - Callback not reaching the calling service in a Clustered environment

In 10g, we had a scenario like shown in the below diagram.


Process A



Process A calls Process B and waits for the call back; after receiving the call back; The Process A calls again the same Process B and waits for the second call back.
This flow is working fine in 10g but after migrating to 11g the second call back is not reaching the Process A.
In the SOA log file we could able to see the below error message -
an unhandled exception has been thrown in the Collaxa Cube systemr; exception reported is: "javax.persistence.PersistenceException: Exception [EclipseLink-4002] (Eclipse Persistence Services - 2.1.3.v20110304-r9073): org.eclipse.persistence.exceptions.DatabaseException
Internal Exception: java.sql.SQLIntegrityConstraintViolationException: ORA-00001: unique constraint (SOA_SOAINFRA.AT_PK) violated

Error Code: 1
Call: INSERT INTO AUDIT_TRAIL (CIKEY, COUNT_ID, NUM_OF_EVENTS, BLOCK_USIZE, CI_PARTITION_DATE, BLOCK_CSIZE, BLOCK, LOG) VALUES (?, ?, ?, ?, ?, ?, ?, ?)
bind => [851450, 5, 0, 118110, 2012-01-12 16:08:04.063, 5048, 3, [B@69157b01]
Query: InsertObjectQuery(com.collaxa.cube.persistence.dto.AuditTrail@494ca627)
at org.eclipse.persistence.internal.jpa.EntityManagerImpl.flush(EntityManagerImpl.java:744)
After the detail analysis and the Oracle SR, the root cause is “Audit Trail caching issue is causing the process not to get to complete due to the exception while doing the second call back”.
Let’s say in a Cluster with four nodes Process A first created on node 1 and carried on and called first call to Process B and dehydrates. Assume that second call hit a node other than node 1, let’s say node 4. Node 4 carries on doing the work and does the second call to Process B and dehydrates. If the second call back hits Node 1, rather than getting the latest audit trail from database, it’s using the cache and trying to update the audit trial with an id which node 4 already used. That’s throwing an exception and rolling back. For that reason the call back is not getting delivered.
As a temporary solution by switching of the audit trail for Process A, it doesn’t try to insert the data into audit trail and the transaction won’t get roll back and the call has reached successfully.

########

Oracle SOA 11g – Skip locking for DBAdapter connection factories in clustered environments

Skip Locking is the new property introduced in 11g for the DBAdapter Connection factories.


“In a distributed scenario, each polling instance will try to balance the load by not greedily attempting to process all unprocessed rows by itself. What that means is that at a time, an instance will only fetch at most MaxTransactionSize rows”.
When using skip locking, if a full MaxTransactionSize rows are fetched, the next MaxTransactionSize rows can be immediately fetched continuously. This is because concurrent threads do no block each other when using skip locking. The Skip Locking offers performance benefits.
However, with skip locking disabled, all threads will try to lock the same rows, and only one will succeed. Consequently, once this thread has processed MaxTransactionSize rows, it will pause until the next polling interval, to allow other threads to also lock and process rows.
If we want to limit the number of records processed(MaxTransactionSize) in a particular polling interval then the SkipLocking should be disabled, the maximum throughput for each node with distributed polling enabled but uses SkipLocking disabled is:
NumberOfThreads x MaxTransactionSize/PollingInterval

########

Persistence Properties in Oracle SOA 11g

BPEL Persistence properties are used to control, when and how a process need to be dehydrated.

inMemoryOptimization

This property indicates to Oracle BPEL Server that this process is a transient process and dehydration of the instance is not required. When set to true, Oracle BPEL Server keeps the instances of this process in memory only during the course of execution. This property can only be set to true for transient processes (process type does not incur any intermediate dehydration points during execution).

  • false (default): instances are persisted completely and recorded in the dehydration store database for a synchronous BPEL process.
  • true: Oracle BPEL Process Manager keeps instances in memory only.

completionPersistPolicy
This property controls if and when to persist instances. If an instance is not saved, it does not appear in Oracle BPEL Console. This property is applicable to transient BPEL processes (process type does not incur any intermediate dehydration points during execution).
This property is only used when inMemoryOptimization is set to true.
This parameter strongly impacts the amount of data stored in the database (in particular, the cube_instance, cube_scope, and work_item tables). It can also impact throughput.
  • on (default): The completed instance is saved normally.
  • deferred: The completed instance is saved, but with a different thread and in another transaction, If a server fails, some instances may not be saved.
  • faulted: Only the faulted instances are saved.
  • off: No instances of this process are saved.
<component name="mySampleBPELComponent">
...
<property name="bpel.config.completionPersistPolicy">faulted</property>
<property name="bpel.config.inMemoryOptimization">true</property>
...
</component>

oneWayDeliveryPolicy
The oneWayDeliveryPolicy is from the Oracle 10g configuration property deliveryPersistencePolicy.The new configuration property name is bpel.config.oneWayDeliveryPolicy.
This property controls database persistence of messages entering Oracle BPEL Server. Its used when we need to have a sync-type call based on a one way operation. This is mainly used when we need to make an adapter synchronous to the BPEL Process.
By default, incoming requests are saved in the following delivery service database tables: dlv_message
  • async.persist: Messages are persisted in the database.
  • sync.cache: Messages are stored in memory.
  • sync: Direct invocation occurs on the same thread.

<component name="mySampleBPELProcess">
...
<property name="bpel.config.transaction" >required</property>
<property name="bpel.config.oneWayDeliveryPolicy">sync</property>
...

########

Increasing the performance of EM console in Oracle SOA 11g

EM console is very slow when accessing to view the composite/component details or the instance details.
We can try to improve the performance by little by following the below steps.
1. Login to the SOA 11g EM Console
2. Right Click on SOA-INFRA and go to SOA Administration->Common properties
3. Set the Data Display Options as shown below.
              Select the option “Disable fetching of instance and fault count metrics. Each metric can still be  retrieved on demand”.
Set the Duration Details to 1 hour (based on your requirement) as shown below.
This will enable to fetch the instance and fault count metrics based on the demand also the default search criteria will display the last one hour data, this will improve the performance of the em console.
Enable fmwctl discovery cache:-
Logging into Enterprise Manager Fusion Middleware Control 11g (fmwctl) takes a long time.  Sometimes as long as 45-60 seconds.  This is often viewed as slow response time, performance or hanging issues, fmwctl discovery is always performed as part of login.  
For installations with thousands of targets, fmwctl discovery may take 45-60 seconds. This delay is expected because EM discovery mbeans need to be invoked for every target.
Solution is to cache the discovery results in the servlet context and use it for subsequent logins. This discovery result will be shared by all the fmwctl users. This will still require the entire discovery to be done at least once.
Follow the metalink note 1423893.1 to enable the discovery caching.
If the caching is enabled, fmwctl will use the cached discovery results and login to the em console will be fast.The default setting is "not use the cached results" 

########

Audit Trail configurations in Oracle SOA 11G

Until 11.1.1.3, BPEL audit trails are saved to database in the same JTA transaction as the main transaction. The below are the some of the issues caused.
  • Latency of saving audit trail to database is included as part of the overall latency of the main business transaction.
  • When the main transaction is rolled back for whatever reason, the audit trail did not get saved, because audit trails are saved in the main transaction as well. Thus no trace of what had happened can be found on the BPEL Console (or EM Console in 11G).
Since SOA 11.1.1.3, management of audit trail memory has been enhanced.

The properties to configure the audit trail:

auditStorePolicy

Use this flag to choose the audit store strategy
syncSingleWrite - would store audit data synchronously when it saves the cube instance, this is done as part of the cube instance transaction.
This is the default value. And the behavior is the same as in the 10.1.3.x version.
syncMultipleWrite - would store audit data synchronously using a separate local transaction.
By "synchronously" it means the BPEL service engine is saving the audit trail in the same thread as the main transaction. However, it is doing it in a "separate local transaction".

Because they are on the same thread, latency of saving audit trail is still included into overall latency of the main transaction.

However, because they are on separate transactions, you can configure BPEL engine (using AuditFlushByteThreshold and AuditFlushEventThreshold) to flush out the audit trail from memory to database periodically regardless how long the main transaction would take.
Moreover, having them on two separate transaction means the rollback of main transaction will NOT affect the audit trail transaction. That is, you will still see audit trail even if the main transaction rolls back.
async - would store the audit data asynchronously using an in-memory queue and pool of audit threads.
This is almost the same as "syncMultipleWrite", except that it is done not just in a separate transaction but also in a separate thread.

The pro is the audit trail latency is NOT directly included in the latency of main transaction (but because they still share the computing resources and database, the latency is still indirectly related).

The con is that because audit trails are being saved asynchronously, the audit trail may be out of sync from the main transaction (as the name 'async' implies).

AuditFlushByteThreshold and AuditFlushEventThreshold
When auditStorePolicy=syncMultipleWrite or auditStorePolicy=async, you use these two flags to control how often the engine should flush the audit events. These two properties do NOT apply to auditStorePolicy=syncSingleWrite.

auditFlushByteThreshold means after adding an event to the current batch, the engine would check if current batch byte size is greater than this value or not. if yes, then it would flush the current batch. The default value is 2048000 (byte), i.e. 2MB.

Similarly, auditFlushEventThreshold means this limit is reached; the engine would trigger the store call. The default value is 300 (event)

Both values need to be tuned based on the application and requirements.

AuditDetailThreshold

This is the maximum size (in bytes) an audit trail details string can be before it is stored separately from the audit trail. The default value is 50000 (byte). This is the same property as in 10.1.3.x.
AuditLevel.this is the same property in 10.1.3.x.

How to Configure

All the above properties can be configured via the SOA EM Console. The path is EM -> SOA ->SOA-INFRA - > SOA Administration -> BPEL Properties -> More BPEL Configuration Properties

########

weblogic.transaction.internal.TimedOutException:Transaction timed out after 301 seconds – Oracle SOA 11g

Frequently the BPEL instances are getting rolled back with the following exception.
 The root cause of the issue is, JTA transaction getting timeout before completing the execution of the BPEL instance; the JTA transaction should be active to complete the execution successfully.
[2012-04-26T05:15:45.139+00:00] [SOA1] [ERROR] [] [oracle.soa.bpel.engine] [tid: orabpel.invoke.pool-4.thread-23] [userId: <anonymous>] [ecid: 0000JRh3heOAxGoqwSuXMG1F_qb^000aP5,0:1:100080683] [APP: soa-infra] [composite_name: AM_Invoker] [component_name: AM_Invoker] [component_instance_id: 5977508] The reason was The execution of this instance "5977508" for process "AM_Invoker" is supposed to be in an active jta transaction, the current transaction status is "MARKED_ROLLBACK" . Root cause: null
 [APP: soa-infra] Error while invoking bean "cube delivery": JTA transaction is not in active state.[[
The transaction became inactive when executing activity "5977508-BpInv1-BpSeq9.78-2" for instance "5,977,508", bpel engine cannot proceed further without an active transaction. please debug the invoked subsystem on why the transaction is not in active status. the transaction status is "MARKED_ROLLBACK".
Message handle error.error while attempting to process the message "com.collaxa.cube.engine.dispatch.message.invoke.InvokeInstanceMessage"; the reported exception is: Transaction Rolledback.: weblogic.transaction.internal.TimedOutException: Transaction timed out after 301 seconds
BEA1-2980B7B48F411EE46991
Solution:
Increase the JTA time out and the BPEL EJB transaction timeout.
Change the JTA transaction timeout:
  1. Log in to Oracle WebLogic Server Administration Console.
  2. In the Domain Structure, select Services > JTA
  3. Increase the JTA transaction timeout value to some higher value like 3600
Change the BPEL EJB transaction timeout settings:
  1. Log in to Oracle WebLogic Server Administration Console.
  2. In the Domain Structure, click Deployments.
  3. Expand soa-infra > EJBs.
  4. Update the following EJBs transaction Timeout value to some higher value like 1200:
 BPELActivityManagerBean
 BPELEngineBean
 BPELInstanceManagerBean
 BPELProcessManagerBean
 BPELServerManagerBean
  1. Click Save.
  2. Restart Oracle WebLogic Server.
There is no standard value for transaction timeout property. We need to trail out and set the value.
If the component still fails with the transaction timeout error then revisit the component design and tune the same.

########

Proxy Configuration in SOA 11g

If we are invoking any web services and it needs to be passed through Proxy then the proxy server details should be configured on soa11g server. In SOA11g we have two ways of configuring the proxy. The first way is to configure the Server Level and the second level is Composite level.
Configuration can be done using Enterprise manager/JDeveloper
1) Server Level from EM console:
 Login to the em console
Navigate to SOA Infrastructure->SOA Administration->Common Properties -> More SOA Infra Advanced Configuration Properties...
Enter the HttpProxyHost, HttpProxyPort, HttpProxyUsername and HttpProxyPassword
Click on Apply and then restart Server



 
2) Composite service Level from EM console:
If we want to configure the configure proxy only to a particular composite the can be configured in composite Level.
Navigate to the Process in EM and in the dashboard click on the Service (Adapter used to invoke the web service to which the proxy is required) under the Services and References section.
Click on the properties tab and you can find the different properties as shown below where you can fill the Proxyhost, ProxyPort.






3) Setting Composite service Level from JDeveloper:
Open the Composite.xml and select the service to which the proxy configuration is required.
Add the binding properties oracle.webservices.proxyHost, oracle.webservices.proxyPort
Click on Save.


########

File/FTP Adapter Threading Model – Oracle SOA 11g

The Oracle File and FTP Adapters use the following threading models:

  • Default Threading Model
  • Modified Threading Model
Default Threading Model:
In the default threading model, a poller is created for each inbound Oracle File or FTP Adapter endpoint. The poller enqueues file metadata into an in-memory queue, which is processed by a global pool of processor threads. We can set the thread count of global processor through the oracle.tip.adapter.file.numProcessorThreads property at the pc.properties file. Create pc.properties file with this property and copy it to server and then reference it in the WLS classpath in setDomainEnv.sh.




The following steps highlight the functioning of the default threading model:
  • The poller periodically looks for files in the input directory. The interval at which the poller looks for files is specified using the PollingFrequency parameter in the inbound JCA file.
  • For each new file that the poller detects in the configured inbound directory, the poller enqueues information such as file name, file directory, modified time, and file size into an internal in-memory queue.
  • A global pool of processor worker threads waits to process from the in-memory queue.
  • Processor worker threads pick up files from the internal queue, and perform the following actions:
  • Stream the file content to an appropriate translator (for example, a translator for reading text, binary, XML, or opaque data.)
  • Publishes the XML result from the translator to the SCA infrastructure.
  • Performs the required post processing, such as deletion or archival after the file is processed.
Modified Threading Model:
We can modify the default threading behavior of Oracle File and FTP Adapters. Modifying the threading model results in a modified throttling behavior of Oracle File and FTP Adapters. The following sections describe the modified threading behavior of the Oracle File and FTP Adapters:
  • Single Threaded Model
  • Partitioned Threaded Model
Single Threaded Model:
The single threaded model is a modified threaded model that enables the poller to assume the role of a processor. The poller thread processes the files in the same thread. The global pool of processor threads is not used in this model. You can define the property for a single threaded model in the inbound JCA file as follows:
<activation-spec className="oracle.tip.adapter.file.inbound.FileActivationSpec">
   <property../>
   <property name="SingleThreadModel" value="true"/>
   <property../>
</activation-spec>
Partitioned Threaded Model:
The partitioned threaded model is a modified threaded model in which the in-memory queue is partitioned and each composite application receives its own in-memory queue. The Oracle File and FTP Adapters are enabled to create their own processor threads rather than depend on the global pool of processor worker threads for processing the enqueued files. You can define the property for a partitioned model in the inbound JCA file as follows:
<activation-spec className="oracle.tip.adapter.file.inbound.FileActivationSpec">
  <property../>
  <property name="ThreadCount" value="4"/>
  <property../>
</activation-spec>
In the preceding example for defining the property for a partitioned model:
  • If the ThreadCount property is set to 0, then the threading behavior is like that of the single threaded model.
  • If the ThreadCount property is set to -1, then the global thread pool is used, as in the default threading model.
  • The maximum value for the ThreadCount property is 40.

########

Deployment plan file to replace the JCA Adapters properties – Oracle SOA 11g

We can create and edit a configuration plan file in which we can replace the following attributes and properties:
  •  Any composite, service component, reference, service, and binding properties in the SOA composite application file (composite.xml)
  • Attribute values for bindings (for example, the location for binding.ws)
  • schemaLocation attribute of an import in a WSDL file
  • location attribute of an include in a WSDL file
  • schemaLocation attribute of an include, import, and redefine in an XSD file
  • Any properties in JCA adapter files
The configuration plan does not alter XSLT artifacts in the SOA composite application. If you want to modify any XSL, do so in the XSLT Mapper. Using a configuration plan is not useful. For example, you cannot change references in XSL using the configuration plan file. Instead, they must be changed manually in the XSLT Mapper in Oracle JDeveloper when moving to and from test, development, and production environments.
Generate the Plan file:
The plan file can be generated through JDeveloper or through ANT script.
Generating Plan file through JDeveloper:
Right Click on Composite.xml and click on generate config Plan.



Change the generated plan file contents accordingly to replace the properties and attributes of the composites.
Change the wsdlAndSchema section accordingly to replace the WSDL location and the schemaLocation of the WSDL’s and XSD’s
   <wsdlAndSchema name="ExplorePlanFile.wsdl|FileAdapter_file.jca|FileAdapter.wsdl|xsd/AA_table.xsd|xsd/ExplorePlanFile.xsd">
      <searchReplace>
         <search>http://localhost:7001/</search>
         <replace>http://10.15.23.24:8004/</replace>
      </searchReplace>
   </wsdlAndSchema>
By default the wsdlAndSchema section will include the jca files to replace the JCA file properties.
The default configuration as shown below is not replacing the jca properties after the deployment of the composite.
<wsdlAndSchema name="FileAdapter_file.jca|FileAdapter.wsdl|xsd/AA_table.xsd|xsd/ExplorePlanFile.xsd">
      <searchReplace>
<search>D://Albin/Files</search>
  <replace>D://Albin/Files/Sample</replace>      </searchReplace>
   </wsdlAndSchema>
The same should be changed as shown below to replace the JCA adapter properties 
File Adapter properties:
<wsdlAndSchema name="FileAdapter_file.jca">
      <jca:property name="PhysicalDirectory">
         <searchReplace>
            <search>D://Albin/Files</search>
            <replace>D://Albin/Files/Sample</replace>
         </searchReplace>
      </jca:property>
       <jca:property name="Append">
         <searchReplace>
            <search>false</search>
            <replace>true</replace>
         </searchReplace>
      </jca:property>     
   </wsdlAndSchema>
MQ Adapter properties:
<wsdlAndSchema name="ENQ_GE_EI_EAI_TRIGGER_mq.jca|OrderStatusMonitorMQAdp_mq.jca">
                <jca:property name="QueueName">                  
        <searchReplace>
            <search>S_Order_Queue</search>
            <replace>P_Order_Queue</replace>
        </searchReplace>
        </jca:property>
   </wsdlAndSchema>
The same searchReplace can be used to replace all the JCA adapters’ properties.
Attaching the plan file while deploying the composite from JDeveloper:
 
The plan file can be attached through ant script during the deployment of the composite to the server.
    <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="${soa.cluster.serverURL}"/>
            <property name="user" value="${soa.user}"/>
            <property name="password" value="${soa.password}"/>
            <property name="overwrite" value="${soa.composite.overwrite}"/>
            <property name="forceDefault" value="${soa.composite.forceDefault}"/>
            <property name="sarLocation" value="${deploy.sarLocation}"/>
            <property name="configplan" value="${deploy.configplan}"/>
        </ant>

########