[jboss-user] [jBPM] - Re: In memory TaskClient without Mina or JMS

Daniele Ulrich do-not-reply at jboss.com
Thu Jul 21 18:33:06 EDT 2011

Daniele Ulrich [http://community.jboss.org/people/daniele.ulrich] created the discussion

"Re: In memory TaskClient without Mina or JMS"

To view the discussion, visit: http://community.jboss.org/message/616860#616860

Hi Franklin

I had already started to do some changes to the classes that are managing persistence. If you like, you can try if it works this way...

You can start the same way as the original version:

TaskService taskService = new TaskService(emf,
   TaskServiceSession taskSession = taskService.createSession();

If you are in a container managed transaction environment, the persistence should work now within the JTA scope without further effort.
In a non managed environment you will have to use UserTransactions and XA Datasources to ensure transactions over multiple databases.There are a lot of implementations available, maybe you try this one  http://docs.codehaus.org/display/BTM/Hibernate13 http://docs.codehaus.org/display/BTM/Hibernate13. You will have to manually start transactions

userTransaction = TransactionManagerServices.getTransactionManager();

try {
System.out.println("*** DB1 ***");
  persistUser(sf1, "user");

System.out.println("*** DB2 ***");
  persistUser(sf2, "user");

catch (Exception ex) {

this way you can keep multiple databases transactional.... Drawback: it definitely will have impact to all the other code you have already implemented that is not using JTA. Try it first without changing your own code, but I'm quite sure, you'll have to use the userTransactions in every situation where you want to guarantee transactions over more than one database.

I did not have the time to test the patch properly, so please take care!

The implementation uses threadLocalStorage and heavily depends on calling the session.dispose() method to perform clean up of the resources of a thread. Make sure it will be called even if an exception occurs ( catch/finally block ).



Reply to this message by going to Community

Start a new discussion in jBPM at Community

-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.jboss.org/pipermail/jboss-user/attachments/20110721/25e3b205/attachment-0001.html 

More information about the jboss-user mailing list