cancel
Showing results for 
Search instead for 
Did you mean: 

Correct Activiti termination

fritz128
Champ in-the-making
Champ in-the-making
What I have:
Activiti workflow, which are managed via Activiti API.

What I want:
Correctly restart server with my application (means correctly stop and renew Activiti's process)

Questions:

1. How could I renew my process with all subprocesses?
2. Now I stop my application via
System.exit(0)
command. Is it acceptable for my purposes?
3. What difficulties I may face?
3 REPLIES 3

jbarrez
Star Contributor
Star Contributor
1. Please explain with what you mean with 'renew' ?

2. you should do ProcessEngines.destroy() to gracefully close down

3. Many, that's how it goes in software development 😉

fritz128
Champ in-the-making
Champ in-the-making
First of all, thank you for reply!

What I mean by renew
Some times I have to restart my service. So I need to suspend all my activities. After restarting I should renew (activate) all  suspended activities and continue workflow.

What I have at the moment:
Suspend all activities:
<java>
for (ProcessInstance processInstance : runtumeService.createProcessInstanceQuery().active().list)
  runtimeService.suspendProcessInstanceById(processInstance.getProcessInstanceId())
</java>
Activate suspended processes:
<java>
for (ProcessInstance processInstance : runtumeService.createProcessInstanceQuery().suspended().list)
  runtimeService.activateProcessInstanceById(processInstance.getProcessInstanceId())
</java>

What a problem:
Suspend doesn't work as I expect. Seems it doesn't work at all! It is clear when you try to use asynchronous subprocess.

I make a demo that illustrate the problem with asynchronous task suspending. You can get it by typing:
git clone https://github.com/JOLO-/Activiti-Process-Suspend-Renew-Demo.git

<ul>
Qustions:
<li>Why after suspendProcessInstanceById method activities proceed their computation?</li>
<li> What I should use destroy metod for? Does it help to solve the previous question? Please more details</li>
<li>How after destroy() renew (activate) process engine again?</li>
</ul>

!!!tasks proceed their computations even after suspension and ProcessEngines.destroy()

About demo:

I workflow looks like: [Main Process] => [Asyncronous Subprocess] => [Return to Main Process]

Each asyncronous process contains infiniti loop that print something each second (AddCandidateService.java).

<ul>
You should look at Main class. There I do next things:
<li>Launch two main processes</li>
<li>For each main process I launch one asynch subprocess (with infinite loop)</li>
<li>Suspend all active processes</li>
</ul>

[Expected result]:
All processes & subprocesses stop their computations

[Actual result]:
Async subprocesses proceed their computations

frederikherema1
Star Contributor
Star Contributor
As mentioned in a previous topic, active running jobs (async service tasks) for that process that is being suspended, will continue and get rolled-back due to optimisitcLockException eventually. The ongoing jobs will NOT be killed, as this is not possible (imagine multiple job)executors on multiple machines executing jobs for the same DB).