cancel
Showing results for 
Search instead for 
Did you mean: 

Activiti and transactions

ganzuoni1
Champ in-the-making
Champ in-the-making
I am rather new to activiti and I am trying to figure out how transaction lifecyle is managed in activiti.
I have read Activiti in Action and checked the source code but I am not so sure to have fully understood when/by who a
transaction i started/completed.
The real life scenario is a JSF app with JDO (DataNucleus) as persistence engine. No Spring, nor annotations.
I have a PhaseListener that take care of starting and completing txn bound the the current FacesContext,
with the app call a setRollbackOnly in case of errors.
Since I don't want to use a real JTA datasource I am putting activiti and application tables in the same database.
From my understanding I should implement a javax.sql.DataSource with getConnection returning the same java.sql.Connection
to JDO and Activiti, while running the same transaction.
Fine and easy (I can bind the connection to the current FacesContext).
As in the SpringTransactionContext (or JtaTransactionContext) I should provide a TransactionContext implementation where
commit() is a NOP while rollback() should just setRollbackOnly in the JDO Transation.
What I miss now is the role of the TransactionInterceptor.
Another thing I don' understand is what should happen when a process starts an async activity.
Is the transaction of the starting activity distinct from the transaction of the async one ?
If so, the transaction of the started activity should be bound to the current thread ?
In the JSF triggered operation, the transaction lifecylce follows JSF lifecycle so I can manage a transaction with a PhaseListener,
in the async case, what is the lifecycle ?
2 REPLIES 2

trademak
Star Contributor
Star Contributor
Did you read the user guide about transactions, synchronous and asynchronous behavior in Activiti? I think that would be a good starting point. The starting point of an Activiti transaction is always to class that's invoking one of the Activiti services, and the transaction ends when the Activiti service has performed it's logic. One simple example is a process definition with a start event, a service task and an end event. When you create a new process instance, the transaction starts and this instance will be fully executed and completed and then the transaction ends and there's no runtime process instance anymore, only one in the history.

Best regards,

ganzuoni1
Champ in-the-making
Champ in-the-making
Thank you for the hint, I'll check.