est Case: There are two table , one is Master and other is Child has primary/foreign key relationship. By a BPEL process we’ll insert the data into Master table and with other BPEL we’ll insert the data into Child in a same composite. But if any error occur while inserting the data into Child it will rollback all transactions in Master table as well.
Solution:Here I’ll use Dept and Emp table as Master and Child table.1st I’ll insert data into Dept and within same global transaction will insert data into Emp. After inserting the data into Emp I’ll throw rollback fault from BPEL and it will automatically rollback the insertion of Dept table data.Here is my composite,
The insertDeptBPEL is synchronous one,
The insertChildBPEL is synchronous one also,
Here in the throw activity,
Now the designing is complete, we need to define the transactional properties now in composite.xml like below,
<component name="insertDeptBPEL" version="1.1">
<implementation.bpel src="insertDeptBPEL.bpel"/>
<property name="bpel.config.transaction" many="false" type="xs:string">requiresNew</property>
<property name="onewayDeliveryPolicy">sync</property> </component>
<component name="insertChildBPEL" version="1.1">
<implementation.bpel src="insertChildBPEL.bpel"/>
<property name="bpel.config.transaction" many="false" type="xs:string">required</property> </component>
Then deploy the run the composite , data will not be inserted in either of the table as it will execute rollback from the code.
Solution:Here I’ll use Dept and Emp table as Master and Child table.1st I’ll insert data into Dept and within same global transaction will insert data into Emp. After inserting the data into Emp I’ll throw rollback fault from BPEL and it will automatically rollback the insertion of Dept table data.Here is my composite,
The insertDeptBPEL is synchronous one,
The insertChildBPEL is synchronous one also,
Here in the throw activity,
Now the designing is complete, we need to define the transactional properties now in composite.xml like below,
<component name="insertDeptBPEL" version="1.1">
<implementation.bpel src="insertDeptBPEL.bpel"/>
<property name="bpel.config.transaction" many="false" type="xs:string">requiresNew</property>
<property name="onewayDeliveryPolicy">sync</property> </component>
<component name="insertChildBPEL" version="1.1">
<implementation.bpel src="insertChildBPEL.bpel"/>
<property name="bpel.config.transaction" many="false" type="xs:string">required</property> </component>
Then deploy the run the composite , data will not be inserted in either of the table as it will execute rollback from the code.
No comments:
Post a Comment