AnsweredAssumed Answered

Basic question on transactions

Question asked by hbf on Dec 4, 2007
Latest reply on Dec 15, 2007 by hbf
Hi list,

A have a few very basic question regarding transactions in Alfresco:

1. Looking at the NodeService Java API, no routine seems to take a transaction as a parameter. This is because every call to the API will run in its own transaction, as documented here. However, if you begin a transaction obtained via getUserTransaction() then the API is using this as the "global transaction". Is this correct so far?

2. Is this global transaction per Java thread?

3. How can I run two independent transactions in parallel? Put differently, how can I make sure that two threads using this global transaction will not run in the same transaction?

I am asking this because my code runs in parallel to the Web Client ("parallel" meaning in the same Tomcat instance, albeit in a different webapp) and I need to start a new, independent transaction at the beginning of a web request and end it later. (I suppose the Web Client, too, needs independent transaction for the potentially different users it is serving…)

4. What does TransactionService's getNonPropagatingUserTransaction() return?

Regarding 4., I've taken a look at the code in and have got the impression that getNonPropagatingUserTransaction() returns a new transaction. However, if I use this routine from my (non-Web Client) webapp once at the beginning of each web request then the Web Client asks me to log in again. So it seems getNonPropagatingUserTransaction() also changes the global transaction.

In other words, what ways does Alfresco give me to run my own transaction? I understand that I need to Spring-configure my transactions but cannot see how. Can you point my to an example/more documentation?

Okay, thanks for your patience. I hope the answers help others as well.