cancel
Showing results for 
Search instead for 
Did you mean: 

Manual DB commit

krpraghu
Champ in-the-making
Champ in-the-making
Hi,
Is there anyway to commit the Activiti related state at any particular point in the code execution without reaching wait state?
I tried 'Asynchronous' and timer event but it didnot commit to the state to DB.
Is there a API method where we can achieve it from java code?

Thanks.
2 REPLIES 2

frederikherema1
Star Contributor
Star Contributor
You cannot do this. Every API-call has it's own command-context. At the end, the changes to the entities are flushed. Most of the times, transactions is also committed right after that, unless participating in an existing container-managed transaction.

If you add "async" to an activity, all progress up until that point will be saved to the database, job will be queued and transaction will be committed BEFORE control is returned to calling thread that did the API-call, causing the process to flow to that activity.

This is just how it works. You can't persists state in the DB unless activiti is certain that is consistent and can be continued at a later point in time (eg. after task complete, after timer fire, …) - exactly the reason why we don't allow forcing commits to the DB.

What is the usecase for this?

krpraghu
Champ in-the-making
Champ in-the-making
Thanks for the reply.
So only way to commit the current instance is to reach a wait state in an activiti flow, makes sense.
I was trying to achieve this through timer event, but it didnt work. Let me try again and see if that works.