My process isn't terminated even if has no tasks left


Hi guys,
I have a little problem. There is a very simple single-path process definition finished with End Event (Terminate End Event).

My code fragment:
tasks = taskService.createTaskQuery()
.list();"Tasks: " + tasks.size());"Is ended: " + processInstance.isEnded());

c.processRuntime.SimpleProcessRuntime : Tasks: 0
c.processRuntime.SimpleProcessRuntime : Is ended: false

I think I’ve finished all tasks associated with the process instance. The problem is that the process is not ended. What can be wrong?


Hi @dikey94,

You may have to fetch the process instance again via RuntimeService#createProcessInstanceQuery. An object returned by the API is always a snapshot of the state when the call was made.

edit: or more precisely: if the instance is indeed finished, then the above query returns no value. Use the history service to access the historic process instance, if required.



Thanks. Is there any case when isEnded() method returns true?


If you start a process instance and immediately completes, e.g. if it contains only service tasks and no asynchronous continuations.


Understand. Thank you.