Wednesday, February 20, 2008

XA transactions with Adapters in BPEL

XA transactions are 2-phase transactions normally used to manage and maintain transaction in a distributed environment. Adapters can be configured for global transactions, if they support the JCA transaction contract. In my first blog lets see how technology adapter (DB Adapter) can be configured to participate in global transaction of BPEL.

Environment: Oracle JDeveloper 10.1.3.2
Integration Server: Oracle SOA Suite 10.1.3.1.0

A BPEL is in place that invoke two DB Adapters, one to debit and another to credit an account. The debit and credit should happen as a single unit of work. These adapters uses different database and hence different datasources. Follow steps below to create datasources -

Oracle JDBC drivers are already available in application server as shared library "oracle.jdbc". If you are going to use third party database, then add the jdbc drivers as shared library. Go to oc4j home > Administration > Shared Libraries and add all jdbc jars.



Under "Applications Importing This Shared Library" section various applications are listed. Applications "ascontrol" and "default" are importing this library to allow us to test the connection of the datasource from the console. Import the shared library to "ascontrol" and "default" by manually adding the entries in "orion-application.xml" and "application.xml" respectively. These files can be found in -

\j2ee\home\application-deployments\ascontrol
\j2ee\home\config

Go to oc4j home > Administration > JDBC Resources and create a new connection pool. Make sure to use a XA datasource as shown in the image below. For Oracle, XA datasource class is - oracle.jdbc.xa.client.OracleXADataSource


Now create a managed datasource and select the newly created connection pool for default application. Provide a jndi name for the datasource like "jndi/OracleDataSource" and make sure to set transaction level as "Global & Local Transactions".

Till now shared library and datasource are established. Now modify the DB adapter deployment descriptor file "oc4j-ra.xml" to add the following entry -


See that the value of xADataSourceName property is the name of datasource created previously. The jndi location for connector-factory is "eis/DB/OracleDBConnection". This should match with the jndi name created by adapter configuration wizard of JDeveloper. See the image below -



Also import the shared library "oracle.jdbc" in oc4j-ra.xml.


Although not mandatory, you can comment the mcf properties in adapter wsdl. In case adapter won't find the jndi location in wsdl or in oc4j-ra.xml, it will fall back on mcf properties.


Change bpel.xml to allow db adapter to participate in bpel process transaction. Add the property "transaction" in bpel.xml as shown in image -




Restart the server and deploy the bpel process so that changes get reflected.



Test the bpel process such that second adapter throws a fault. The account debit done by first adapter should rollback.

1 comment:

Unknown said...

Thanx for sharing ur knowledge..U have done a grt job..This blog is really very helpful..