cancel
Showing results for 
Search instead for 
Did you mean: 

Activiti process variables persistence

jolo_
Champ on-the-rise
Champ on-the-rise
In my project I use Activiti + Hibernate + Spring. For atomicity reasons, Activiti and Hibernate share the same database and transaction manager. I've read "Activiti in Action" book and a dozen of topics, but it is not still clear for me:
1. When Activiti proceed process-variables persistence to database?
2. Why Activiti does not save any process variables into ACT_RU_VARIABLE and ACT_GE_BYTEARRAY tables?
5 REPLIES 5

trademak
Star Contributor
Star Contributor
1. Process variables are persisted to the database when a wait step like a user task or an async task is executed. The history variables table is also updated when a process is completed.
2. And why do you ask this question? Because it does save process variables in ACT_RU_VARIABLE

Best regards,

jolo_
Champ on-the-rise
Champ on-the-rise
First of all - thanks for fast reply.
Nope, there is another reason why I've asked this question:

What I have:
In my project I use Spring+Hibernate+PostgreSQL. And I'm just begining to integrate Activiti in my project. I concerns about integrity issues:
My entities will be stored in both databases App & Activiti. So I decided to use the common database and the common transaction manager for App & Activiti (example I took from here http://forums.activiti.org/content/activiti-hibernate).

Problem:
It seems that Activiti still doesn't share the same transaction as Hibernate. For example (action sequence):
1. start activiti-process
2. open hibernate session
3. begin transaction
4. save entity into App's DB via hibernate session //rollback correctly
5. save entity into Activiti process context via execution.setVariable method //BUT, I want to rollback this step!!!!
6. rollback transaction
7. end activiti-process
After that (step 7), Activiti save entity to ACT_GE_BYTEARRAY & ACT_HI_DETAIL.

Question:
Consult me, please, what is the best way to achieve data integrity in such case:
1. How to rollback activiti changes?
2. Can I flush Activiti process variables manually, not before the wait state or asynch task?
3. What is the best practice to rollback? in both cases:
    3.a When hibernate transaction fails but activiti works fine
    3.b When activiti fails but hibernate works fine
4. What about extended conversation? What difficilties I'll face with it?

Thank you in advance!

trademak
Star Contributor
Star Contributor
Hi,

1. When you want to rollback changes in Activiti you can throw an exception and everything will get rollbacked to the previous wait step.
2. No you can make a service task async for example and that makes the engine flush the process instance including its variables.
3. Don't understand, when you want to rollback just rollback the transaction
4. Don't understand the question. What do you mean with extended conversation?

Best regards,

jolo_
Champ on-the-rise
Champ on-the-rise
Thanks for reply!
I want to clearify some moments:
3.  I want to rallback the activiti changes without throwing an exception. Is it possible?
4. I mean session-per-conversation in Hibernate. Actually it means no @Transactional annotation in methods, but manual transactions commitiong and fkushing. I' ve heard that there are some problems with manual flush mode in Hibernate with Activiti. When Activiti use the same transactional manager as Hibernate (in FlushMode.MANUAL), Activiti can invoke flush mode without session.flush.

trademak
Star Contributor
Star Contributor
Hi,

3. We are using standard transaction manager behavior, so it's not Activiti functionality but transaction manager functionality. Activiti forwards the commit behavior to the transaction manager, which is then responsible to do a commit or a rollback.
4. Ok, like said in 3 the transaction manager is responsible for commit and rollback, so yes Activiti does support manual transactions.

Best regards,