cancel
Showing results for 
Search instead for 
Did you mean: 

Activiti + CDI / Transactions (Timing Issue)

joshb1
Champ in-the-making
Champ in-the-making
I am running into a problem - I'm just trying to get Activiti + CDI setup.  I am so close I can taste it, but need to get over this hump.

I have a very simple use case: I am starting a process, and listening using CDI events (@Observes) for certain activities to start and end.  I have an activity that starts after the process starts.  I start my process, and the even is fired and it gets to my method without any problems.  My BusinessProcessEvent object is populated with all the right data.  Once I'm in this method, I want to load the processInstance, or do something, and the instance (and execution) isn't found by the queries.  It looks like it is a timing issue, in that it isn't written to the DB until after the transaction completes.  How should I handle this use case?
2 REPLIES 2

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
I don't think it is a timing issue, it is just the way things work. What you could try is make the first task async. That way things will be committed to the database at the beginning of the process.

joshb1
Champ in-the-making
Champ in-the-making
ronald,

Thanks for pointing me in the right direction.  As I said, I'm new to Activiti Smiley Happy.  Using asynchronous tasks did the trick (somehow I missed that part of the documentation - http://activiti.org/userguide/#bpmnConcurrencyAndTransactions ).