cancel
Showing results for 
Search instead for 
Did you mean: 

Flushing activiti DB updates on Demand

jorell
Champ in-the-making
Champ in-the-making
I am facing a case where it seems that when I start process and immediately complete the first task (from outside the delegate) the execution for that process hasn;t yet been persisted to the DB. I am unable to fetch the execution by id. My first service task is a delegate which does some work and then send its execution id to an external system which is responsible for finishing that task. But there seems to be a race condition in that it can try to complete the task before activiti has flushed its cache.
Is there a way for force activiti to flush its cache after a operation like starting a new process?
3 REPLIES 3

martin_grofcik
Confirmed Champ
Confirmed Champ
Hi Jorell,

Is there a way for force activiti to flush its cache after a operation like starting a new process?
Try to use async executions. http://www.activiti.org/userguide/#asyncContinuations

immediately complete the first task (from outside the delegate) the execution for that process hasn;t yet been persisted to the DB. I am unable to fetch the execution by id.
Would it be possible to create jUnit test?

Regards
Martin

jwood
Champ in-the-making
Champ in-the-making
Hi, I just faced the same problem. The first step in my process is a java service which invoked a method via an EL expression. Any attempt to set a variable in that method fails because the process cannot be found. The async suggestion doesnt work for me as I want to immediatly return from the process create knowing where the flow has got to.

I have a work around by putting a Receive Task immediatly after creation and signalling it straight after returning from the startProcessInstanceByKey call. This seems to ensure that the execution is written to the DB.

Is there any way of avoiding this extra step?

jbarrez
Star Contributor
Star Contributor
Another solution could be to put a little queue thing in front of that logic, that keeps the message until the process has reached a persistent state.