AnsweredAssumed Answered

flow and db transaction?

Question asked by vipi_voxa on Jan 12, 2017
Latest reply on Jan 13, 2017 by gdharley

Hello guys,

Please help me to get rid of my darkness. I am new to Activiti and BPMN and i am apologizing for this in advance. I have installed eclipse activiti designer, i have managed to get activiti-explorer 5.22 up & running on jboss together with activit-rest ,all works fine, db is oracle. But...


But ... I think i missing some crucial point in understanding of how to work with Activiti Bpmn. 


Let's keep it simple, lets say I have a process "A" which i designed in Eclipse Activiti Desiner and deployed to my Activiti instance running on my server.


Process "A" has an incoming parameter, lets call it "test_table_id". And the process at some point needs to update DB table. E.g. in my flow i need to execute "update test_table set processing_status='S' where test_table_id=${test_table_id}" as one of the steps.


Simple structure of the flow:

Process "A": starts -> UserTask to User "Mr.X"->"Mr. X" completes task-> Update DB table action -> Other actions ->ends


Sounds and looks easy - but how to implement correctly? First question: What type of activiti event is suitable for DB update call?

At the moment I have created groovy ScriptTask which is calling java code. This java code updates DB. It Works, but doesn't  look like a correct approach, because i am making, calling, committing and closing jdbc connection inside that java. But how to handle commits and rollbacks then afterwords in a flow? What if Other Actions fails? In my created diagram the task stays active if 'Other actions' failed, means user can complete task again and then update db action (which i implemented via scriptTask) is performed again.



Please fellows, advice me with best practice hints,

thank you!