rss
SOATUBE
Oracle
Custom Search SOABYTE here

Monday, October 11, 2010

SOA Suite 11g Transaction Semantics Part 2



By default  BPEL will create a new transaction on request basis - that is if one already exists, it will be suspended, and a new one created. Upon completion of the child, the master one resumes. 
                         
However, if the request is async (that is one-way) we either inherit the transaction for the insert into the dehydration store (that is dlv_message in this case) or if one exists enlist transparently into it. So we guarantee you zero message loss. Either the invocation message is in the dehydration store, to be processed, or otherwise the consumer is notified via a fault.
One only needs to set the (new) transaction flag on the calee bpel component. This can be done in the composite editor's source by adding bpel.config.transaction into a bpel component - as shown below


  <component name="SampleProject">

    <implementation.bpel src="SampleProject.bpel"/>

    <property name="bpel.config.transaction"

         many="false" type="xs:string">required | requiresNew</property>

  </component>
The two possible values are 
1> required, which makes BPEL inherit the tx that is already there, or if not creating a new one
2> requiresNew which makes BPEL suspending one if exists, and ALWAYS create a new one 
                     

Implications of setting the above (the default is requiresNew)


Case one - BPELCaller calls BPELCallee (the latter has requiresNew set)

a) BPELCallee replies (that is uses <reply>) with a fault: BPELCallee transaction is saved, BPELCaller get's the fault and can catch it.
b) BPELCallee throws (that is uses <throw>) a fault, that is NOT handled: BPELCallee tx get's rolled back, BPELCaller get's the fault and can catch it
c) BPELCallee replies back with a fault (FaultOne), and then throws a fault (FaultTwo): BPELCallee tx get's rolled back, and BPELCaller get's FaultOne
d) BPELCallee throws (that is uses <throw>) a 
bpelx:rollback fault: BPELCallee tx get's rolled back, BPELCaller get's a remote fault

Example:--

Create two processes (BPELMaster and BPELChild), both sync, each using the same db adapter reference that inserts the same record (and hence causes a PK violation). (And of course has set xADatasourceName). In this case
                 
Once the fault occurs, and is not handled - the BPELChild will rollback. If the BPELMaster has a catch block his transaction will commit, so you end up with the record from the Master in the db.If you don't catch the fault in the master as well - you get a second rollback - two different transactions though.

Case two - BPELCaller calls BPELCallee (the latter has required set)
a) BPELCallee replies (that is uses <reply>) with a fault: BPELCaller get's the fault and can catch it, BPELCaller owns the transaction - hence if he catches it - tx is committed, if BPELCaller does not handle it - global rollback.
b) BPELCallee throws (that is uses <throw>) a fault BPELCaller get's the fault and can catch it
c) BPELCallee replies back with a fault (FaultOne), and then throws a fault (FaultTwo): BPELCaller get's FaultOne
d) BPELCallee throws (that is uses <throw>) a 
bpelx:rollback fault: BPELCaller tx get's rolled back, no way to catch it.

Example :--

Create two processes (BPELMaster and BPELChild), both sync, each using the same db adapter reference that inserts the same record (and hence causes a PK violation). (And of course has set xADatasourceName). In this case
 If no fault handlers are in place - the whole tx will rollback, based on the BPELMaster's unhandled fault.With a fault handler in the BPELMaster to catch the Fault from the BPELClient - and throw up a rollback fault. Globally the tx will rollback as well.

Note :-- tx stands for ongoing transaction


0 comments:

Post a Comment

 
Blogger Profile