Flowable API for contriving all the "tasks" (BPMN constructs : user tasks, system tasks et al.) as an ordered list?

I have a use case where I want a view on all the tasks (BPMN constructs) configured in the BPMN, in the order of the actual sequence flow, at runtime.

For instance,
If the process definition can be represented as
{U1 -> S1 -> U2 -> S2},
where U and S denote “user” and “service” tasks respectively, and the arrows represent the sequence flow,

I want a way to retrieve (directly or indirectly) the following :
[U1, S1, U2, S2]

Note that I cannot use the APIs of the RuntimeService, as those will be limited to the scope of active executions. For instance, if the process is waiting on U2, I can retrieve the context [U1, S1, U2] at best, through RuntimeService.

P.S : I am new to Flowable, and might have misinterpreted or missed out essential details. Please feel free to let me know if this is the case.

Hi Virajbajoria.

Use HistoryService.
Have a look on the following jUnit test:



For a use-case like mine, HistoryService will be useful only if there has been at-least one complete execution of a process instance for a process def.

If there have been no process initiations for the process def yet, or if it’s the first ever execution of the process instance and the process instance is in a wait state,
HistoryService would not give me any/all of the tasks(a.k.a activities) : A limitation similar to the one with RuntimeService about which I have mentioned in the description.


In that case you can traverse BPMN model and collect all activities in the right order (take into account gateways, loops, etc.)