Tuesday 15 December 2015

SOA - DB Polling Issue in Cluster environment

DB Polling Issue in Cluster

DB Polling is always a challenging requirement. Often we encounter various issues with polling, be it not picking up the record or not updating the status. Some times we can see there are duplicate BPEL instances created for the same record.
The duplicate instances mainly happens in clustered environment where as each node will try to poll the same record.

This can be avoided in two ways

  • One by choosing the Distributed Polling option while configuring the DB Adapter. Once this is selected it means the record is locked by the reading instance. No other instance can read the record. In that way duplicate instances can be avoided



  • The second approach is to set a singleton parameter for the JCA in the composite.xml

<binding.jca config="triggerTransaction_db.jca">
<property name="singleton">true</property>
</binding.jca>




In this case too only one node will poll the record and duplicates will be avoided.

DB Adapter polling tricks..!!

The commonly used polling strategies with Oracle DB adapter are:

1. DeletePollingStrategy : This is simplest where we read all possible rows from table and delete them afterwards to ensure that they are only read once.

2. LogicalDeletePollingStrategy : This is a non-intrusive polling mechanism where we update a status column to mark records as read rather than deleting them. This uses 2 SQLs -- one for polling/reading the records and another after-read SQL to update/mark the records as read.

3. LastReadId or SequencingPollingStrategy : This takes help of an external sequencing/helper table. This assumes that all new rows are inserted with an increasing key so that when selected only records with key greater than the highest key previously processed are fetched. This last highest key is stored in the helper table.

TopLink is the technology on which the DbAdapter is built and the DBAdapter UI generates some files especially toplink metadata or -mappings.xml file which can be hand edited to extend the polling mechanisms.

There maybe cases where you would like to use logical delete with custom SQLs instead of Toplink generated SQL to poll DB tables.In order to achieve this please make sure below steps are followed:

1. Pure SQL will not be executed by Toplink if you choose the second option (Logical Delete) as the After Read Strategy in Adapter Configuration Wizard.
2. To make Pure SQL work with Logical Delete Strategy, you must choose the first option (Delete the rowsas the After Read Strategy in Adapter Configuration Wizard, then edit the toplink project directly by adding two custom SQLs, one for polling, the other for after reading operations.
3. For editing the toplink project open the -or-mappings.xml outside of Jdeveloper (the file is write protected) and add below entries:
?
1
2
3
<toplink:call xsi:type="toplink:sql-call">
<toplink:sql>Enter your SQL here</toplink:sql>
</toplink:call>
When adding the <toplink:call> element, it must be under <opm:query>. Also immediately after <opm:queries>and before <opm:querying> add this element:
?
1
2
3
4
5
<toplink:delete-query xsi:type="toplink:delete-object-query">
<toplink:call xsi:type="toplink:sql-call">
<toplink:sql>Enter your After read SQL here</toplink:sql>
</toplink:call>
</toplink:delete-query>
There maybe cases where you would like to control the number of DB records which are polled at a time. The DB adapter wizard gives several configurable properties which can control this.


1. Polling frequency is the interval at which the DB adapter activation agent polls the new records.

2. Database Rows per Transaction (default value of 10) controls the number of records which are read at a time. For eg. if there are 1000 records to be read and we set the Database Rows per Transaction=10 , at the start of the polling interval the entire work is divided into 1000/10=100 transaction units and completes sequentially till all are processed. This property resolves to MaxTransactionSize in the jca file.

3. If we enable the distributed polling checkbox and set the MaxTransactionSize the behaviour changes. Here the entire work is divided into 100 transaction units but each unit is processed in a single polling interval i.e 1st polling interval 10 records are processed, rest 990 will be processed in subsequent intervals.

Oracle SOA suite 11g (11.1.1.7) Installation steps for windows 7...!!!

This installation is for a Windows 7 based machine.
You can use these instructions for both 32 and 64bit machines. 
You will need at least 4GB of RAM to install all the required components for Oracle SOA Suite 11g. 

You will need to download the following files to proceed with the installation.
Go to Oracle SOA suite download page here.
Under Oracle SOA Suite 11g Installations, select release 11.1.1.7 and then Microsoft Windows 32-bit JVM.

Download the following files.

  • Database (OracleXE112_Win32.zip).
  • WebLogic server (wls1036_win32.exe)
  • Repository creation utility (ofm_rcu_win_11.1.1.7.0_32_disk1_1of1.zip).
  • Jdeveloper (jdevstudio11117install.exe).
  • SOA (ofm_soa_generic_11.1.1.7.0_disk1_1of2.zip and ofm_soa_generic_11.1.1.7.0_disk1_2of2.zip) You need to download Jdeveloper SOA extension from a different location.
  • Jdeveloper SOA extension (Download from here)
 
You need to install these in the following order:
  1. Database.
  2. WebLogic server.
  3. Repository creation utility.
  4. SOA.
  5. Jdeveloper.
  6. Jdeveloper SOA extension. 




  • 1) Install the database

    Extract the contents of OracleXE112_Win32.zip to a folder and run setup.exe
    Image 001


    Click next in the following screen

     Image 002





    Accept the terms in the following screen and click next
    Image 003





    Use the default location or change to a location without space In the path.
    Click Next.
    Image 004





    Now, go to the following location :
    C:\Users\user_name\AppData\Local\Temp\{E839CC91-1523-4497-BCFD-5C22565F8553}
    Replace user_name with the logged in username. The last entry in the path might be different for you.
    Make a copy of OracleMTSRecoveryService.reg and rename the copy to KEY_XE.reg
    Now proceed with the installation.
    Image 005


    You can specify a password for the SYS user in the following screen.
    Use welcome1 as the password.
    Image 006





    Review the details and click install.
    Image 007





    Once the installation is complete, click finish.
    Image 008





    Now we need to increase the session and process limit for the database.


    Open SQL Command line From the start menu.

    Image 009





    Run the following commands at the SQL prompt.

    connect sys/welcome1@XE as sysdba
    show parameter session
    show parameter processes
    alter system reset sessions scope=spfile sid='*';
    alter system set processes=300 scope=spfile;

    You will see the following output.
    Image 010
    Image 011

    Image 012





    After running the above commands, stop and start the database

    Image 013





    Open SQL command prompt and run the following commands to verify that the session limit has increased.

    connect sys/welcome1@XE as sysdba
    show parameter session
    show parameter processes
    You should see the following output.
    Image 013





    2) Install WebLogic Server

    Open wls1036_win32.exe
    Click Next.
    Image 007





    Select ‘Create a new Middleware Home’.Give the directory path as C:\mw_home If you want to install in any other location, make sure there are no spaces in the path.
    Click Next.
    Image 008







    Deselect the checkbox to receive security updates and Click Next.
    Image 009





    Select Typical installation and Click Next.
    Image 010





    Review the directories and Click Next.
    Image 011





    Click next.
    Image 012





    You will see the summary of installation. Click next.
    Image 013





    Uncheck ‘Run Quickstart’ and Click Done when the installation completes.
    Image 015





     

    3) Create DB schema using RCU

    Extract the contents of ofm_rcu_win_11.1.1.7.0_32_disk1_1of1.zip to a location without any spaces in the path. for e.g. X:\rcuHome

    Open Command Prompt to the following location: X:\rcuHome\BIN
    Run the following commands:

    set RCU_JDBC_TRIM_BLOCKS=TRUE
    echo %RCU_JDBC_TRIM_BLOCKS%
    rcu.bat

    You will see the following output.
    image







    Click next.
    Image 122





    Select Create and click next.
    Image 123





    Enter the following details:
    Database type: Oracle databaseHostname: localhost
    Port:1521
    Service name:XE
    Username: SYS
    Password:welcome1
    Role:SYSDBA
    Click next.
    Image 124
    You can ignore the following warning.
    Image 125

    Click ok  after the prerequisite check.
    Image 126





    Select SOA and BPM infrastructure.
    The dependent components are automatically selected.
    Click next.
    Image 127

    Click ok after the prerequisite check.
    Image 128`





    Select “Use same passwords for all schemas” and enter the password as welcome1
    Click next.
    Image 129





    Click next in the following screen.
    Image 130`
    Click ok to create the table spaces.
    Image 131
    Click ok after the table spaces are created,
    Image 132`





    Click on Create to start creation of the required schemas.
    Image 133








    Click on Close after all the schemas are created successfully.
    Image 134






    4) Install SOA

    Extract the contents of ofm_soa_generic_11.1.1.7.0_disk1_1of2.zip andofm_soa_generic_11.1.1.7.0_disk1_2of2.zipto a folder without any spaces in the path.
    For example: X:\soa 

    Open command prompt to the following directory: X:\soa\Disk1
    Run the following command: setup.exe –jreLoc C:\mw_home\jdk160_29
    The jre location is pointing to the JDK installed automatically your middleware home.

    image





    Click Next in the above screen.
    Image 137






    Skip software updates and click Next.
    Image 138





    Click Next. After the prerequisite check.
    Image 139





    Select the middleware home C:\mw_home and click next.
    Image 140





    The WebLogic server will be detected.
    Click next.
    Image 141





    Review the directory details and click Install.
    Image 142






    Click Next after the installation completes successfully.
    Image 144






    Click Finish.
    Image 145







    4.1) Create SOA domain

    Go to start –> Programs –>Oracle SOA 11g - Home1 and click ‘Configure Application Server’
    image





    Select ‘Create a new WebLogic domain’ and click next
    Image 147





    Select ‘Oracle SOA suite for developers’, ‘Oracle enterprise manager’ and ‘Oracle business activity monitoring’.
    The dependent components if any will be automatically selected.
    Click Next.
    Image 148





    Enter a domain name. For example, soa_domain
    Click Next.
    Image 149





    Enter the following details
    Name:weblogic
    Password: welcome1
    Click Next.
    Image 150





    Select ‘Development Mode’ and ‘Sun JDK’.
    Click Next.
    Image 151





    First, select all the checkboxes for all schemas.
    Then enter the following details:
    Service: xe
    Hostname: localhost
    Port:1521
    Schema Password: welcome1
    Click Next.
    Image 152





    Click Next after all the tests are completed successfully.
    Image 153





    Don't change anything. Click Next.
    Image 154





    Review the details and click create.
    Image 155





    Once the domain is created, click done.
    Image 156






    5) Install JDeveloper


    Open jdevstudio11117install.exe
    Click Next.
    Image 001





    Select ‘Create a new middleware home’.Give directory as C:\mw_home_jdev
    Click Next.
    Image 002





    Select complete and Click Next.
    Image 003





    Click Next.
    Image 004





    Click Next.
    Image 005





    Click Next to finish the installation.
    Image 006





    5.1) Install JDeveloper SOA Extension

    Open jdeveloper from the start menu.
    Image 001




    Select ‘Default Role’ and uncheck the checkbox 'Always prompt for role selection on startup'.
    Image 080





    Go to Help –>  Check for Updates
    image





    Click Next.
    Image 082





    Select install from local file.
    Browse for file soa-jdev-extension.zip and open.
    Click Next
    Image 083






    Click Finish.
    Image 007





    Click Yes to restart the JDeveloper and finish the installation of the SOA extension.
    Image 086



    Once Jdeveloper restarts, Go to Help –>  About
    Image 009




    In the Extensions tab you should see ‘Oracle SOA Composite Editor’
    Image 010





    Starting and Stopping the SOA server

    Go to ‘All Programs’ in the start menu.
    Go to Oracle WebLogic –> User Projects –> soa_domain
    Click ‘Start Admin Server for Weblogic’
    Image 016




    The server will take a couple of minutes to start.
    Once the server starts successfully you should see the following message.
    SOA Platform is running and accepting requests
    Image 017





    To stop the server, press CTRL+C in the server window.



  • Finally enjoy with SOA world ..!!!