cancel
Showing results for 
Search instead for 
Did you mean: 

Starting process executes all tasks

sgarbaciak
Champ in-the-making
Champ in-the-making
I've created process with two task MailTask and ScriptTask (execute script task take 2 minutes). I start the process
ProcessInstance processInstance = runtimeService.startProcessInstanceById(processId)
and get the processInstance after all tasks were executed. Is this normal behaviour in Activiti? I expect to get processInstance after process started but before executed any task.
4 REPLIES 4

gant
Champ in-the-making
Champ in-the-making
Hi,

This is the normal behaviour, as long as you don't have wait states (user task, receive task) in your process model, the process is executed synchronously. If your process contains wait states, the process runs to the first wait state and gets persisted there, the startProcessXXX() method then returns.

regards,
michael

sgarbaciak
Champ in-the-making
Champ in-the-making
Thanks for explanation. So I have second question: I plan to implement complex ScriptTask (aproximetly it takes 3-5 hours) after start process. Is there any method to run this script  asynchronously?  I need a information that process start properly and after that in background execute ScriptTask.

trademak
Star Contributor
Star Contributor
Hi,

Sure. What you can do is include a receive task before the complex script task. Then, when the process is started you get the process instance info back and then you can signal the process instance in a separate thread or Java 6 Future to let the script task run asynchronously.

Best regards,

ronald_van_kuij
Champ on-the-rise
Champ on-the-rise
or vote for ACT-126