cancel
Showing results for 
Search instead for 
Did you mean: 

Force Process to Persist

flavio_donze
Champ in-the-making
Champ in-the-making
Hello

Is there a simple way or workaround to force a process to persist?

As discused in http://forums.activiti.org/content/transaction-deadlock, I have a process which only consists of a few service tasks.
The deadlock problem was solved as I changed the process to run asynchronous.

I have one important use case though, where I need the process to run synchronous (return from the service call after the process is done).

I need the process to be persistent since I'm reading the data during the process (create a XML for history purpose).

Here (http://forums.activiti.org/content/how-persist-process-state-between-2-javadelegates) I read:
"you either have to include a (non-functional) waitstate for this e.g. with a timeout on it of 1 second, or wait for the 'async' functionality (http://jira.codehaus.org/browse/ACT-126) to be implemented."

I tried the following:
<receiveTask id="persist" name="persist"/>
<boundaryEvent id="persistTimer" cancelActivity="true" attachedToRef="persist">
   <timerEventDefinition>
      <timeDuration>PT1S</timeDuration>
   </timerEventDefinition>
</boundaryEvent>
<sequenceFlow id="persistTimerToCommit" sourceRef="persistTimer" targetRef="commit"/>

But the service returns immediately and the process runs in the background.

I also had a working "hack" with the receive task, which was signaled after the process was started.

Is there an option to force the process to persist, without hacking?
Or is there an official workaround?

greets and thanks ahead
Flavio
2 REPLIES 2

flavio_donze
Champ in-the-making
Champ in-the-making
Here the code for "I tried the following:" from above:
<code>
<receiveTask id="persist" name="persist"/>
<boundaryEvent id="persistTimer" cancelActivity="true" attachedToRef="persist">
<timerEventDefinition>
  <timeDuration>PT1S</timeDuration>
</timerEventDefinition>
</boundaryEvent>
<sequenceFlow id="persistTimerToCommit" sourceRef="persistTimer" targetRef="commit"/>
</code>

trademak
Star Contributor
Star Contributor
Hi Flavio,

Activiti works in one database transaction when executing synchronously. So to force Activiti to persist the process state you would need to introduce an asynchronous element to it. So no workaround for this as this is one of the architectural foundations of the engine.

Best regards,