I was wondering how I could get a list of all processInstances that are alive on a runtime service. With alive I mean all instances, including instances in wait state and currently processing something.
As I understand, as soon as a processInstance hits a wait state, e.g. user task, the entire process isntance is persisted into a database able?
If so, then there are some processInstances in a database table, which I could query, and some are not (only alive somewhere in runtime environment). What would be your approach to retrieve those instances?
Also, how can I force a processInstance to persist itself upon process start? Basically when it enters the start node? Not only for this task, but also in case the process engine crashs and I have to restore all instances.
Yes if you hit a wait state the state is persisted. If you want every process instance to persist itself immediately it's a good idea to add an async task right after the start event. This can even be a dummy manual task.