[jboss-user] [jBPM] - using JTA Transactions in jBPM 3

Sascha Janz do-not-reply at jboss.com
Tue Aug 20 12:14:15 EDT 2013


Sascha Janz [https://community.jboss.org/people/AJanz] created the discussion

"using JTA Transactions in jBPM 3"

To view the discussion, visit: https://community.jboss.org/message/833238#833238

--------------------------------------------------------------
Hello,

we are still using jBPM 3.2.3. ( seam and richfaces for frontend ) 

Due to some data inconsistencies between jBPM and our data, i wanted to use JTA Transactions to get control over commit and rollback. 

although i read the documentation i am not quite sure how to use it the right way. 

in jbpm.cfg.cml  isTransactionEnabled must still set to false, is that right  ? 

in hibernate.cfg.xml i change to JTA
<property name="hibernate.transaction.factory_class">org.hibernate.transaction.JTATransactionFactory</property>
  <property name="hibernate.transaction.manager_lookup_class">org.hibernate.transaction.JBossTransactionManagerLookup</property>
  <property name="jta.UserTransaction">java:comp/UserTransaction</property>

Now i want to set the commit and rollback points in our code. i wrote a simple class TransactionManager with three methods "beginTransaction" , "commitTransaction" and "rollbackTransaction".

every method in our code with write access, i extended with these three methods.

beginTransaction does the following

[code]
// creating new context and store in a ThreadLocal
 jbpmContextThreadLocal.set(cfg.createJbpmContext());
// on this context start a hibernate transaction 
 Transaction  tx = jbpmContextThreadLocal.get().getSession().beginTransaction();
// and store it also in  a ThreadLocal
        userTransactionThreadLocal.set(tx);


[/code]

commitTransaction

[code]
  
          userTransactionThreadLocal.get().commit();
   userTransactionThreadLocal.remove();

    //  explizites flush!
    // s. unter  http://grepcode.com/file/repository.jboss.org/nexus/content/repositories/releases/org.jboss.seam/jboss-seam/2.0.0.GA/org/jboss/seam/bpm/ManagedJbpmContext.java http://grepcode.com/file/repository.jboss.org/nexus/content/repositories/releases/org.jboss.seam/jboss-//seam/2.0.0.GA/org/jboss/seam/bpm/ManagedJbpmContext.java

                  jbpmContextThreadLocal.get().getSession().flush();
    jbpmContextThreadLocal.get().close();
    jbpmContextThreadLocal.remove();
[/code]




 and rollback
[code]
      userTransactionThreadLocal.get().rollback();
     userTransactionThreadLocal.remove();

      jbpmContextThreadLocal.get().close();
     jbpmContextThreadLocal.remove();
[/code]


is this a right way to use JTA Transaction with jBPM ? 

or am i doing something wrong?++
--------------------------------------------------------------

Reply to this message by going to Community
[https://community.jboss.org/message/833238#833238]

Start a new discussion in jBPM at Community
[https://community.jboss.org/choose-container!input.jspa?contentType=1&containerType=14&container=2034]

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20130820/ad8a06ee/attachment.html 


More information about the jboss-user mailing list