Implementing 2 phase commit in Websphere application server

I am new to two phase commit in Websphere application server. Is two phase commit related to JTA transaction factory?

In my scenario, i am going to use two resources.one is JMS and another is SQL Server database using hibernate in java.

In my case, if i getting any exception in any resources and then both will rollback.

Case 1:

In my message driven bean, if i first call JMSProducer method and 2nd call database stored procedure call. If i getting exception in 2nd method call (database call) and then JMS Produced message also rolledback and this scenario working fine.

Case 2:

In that case, i 1st called database and then Jms producer. if i getting exception in JMS and then database stored procedure call not rolled back.

Details:

  1. In ejb-jar.xml file, I added message driven bean resource only.

  2. In hibernate.cfg.xml file I added JTA transaction factory as a property.

Kindly provide solution for this and sample logic also.

Trying to rollback the resources, when getting exception

Leave a Comment