I’m using Flowable 7.1 embedded with PostgreSQL. We have a requirement for ultra-low execution time, so our BPMN processes include only synchronous steps (async = false).
As runtimeService.startProcessInstanceByKey waits for all synchronous steps to complete, I intend to retrieve process variables directly from the ProcessInstance object, avoiding any history table queries for performance reasons.
However, I came across a note that if the BPMN includes scripts or sub-processes, not all variables may be available on the ProcessInstance. Could you confirm if this is true?
This is critical for our use case, and your clarification would be greatly appreciated.
The process variables retrieved through ProcessInstance after starting it should return all process instance variables. If you had some local variables or if you didn’t map the output variables from a Call Activity then you won’t see those. However, that’s entirely on you how you model your process.
e.g. if you used execution.setLocalVariable then you will not see that variable in the process variables. However, if you do execution.setVariable you should be able to see it.
All the variables that are direct variables of the process instance. However, if you are using local variables, then it won’t return those.
e.g. if you have a sub process, and in this sub process you have a script task in which you do execution.setLocalVariable, then this variable will not be a process instance variable, but a local variable to the sub process.
@filiphr We’re facing challenges in achieving ultra-low latency (~50 milliseconds) for synchronous workflow execution under load. On closer inspection, I noticed that even a single workflow execution triggers several database queries, such as:
SELECT * FROM ACT_RU_EXECUTION WHERE PARENT_ID_ = ?
SELECT * FROM ACT_RU_EXECUTION WHERE PROC_INST_ID_ = ? AND PARENT_ID_ IS NOT NULL
SELECT * FROM ACT_RU_EXECUTION WHERE SUPER_EXEC_ = ? (executed twice)
SELECT * FROM ACT_RU_VARIABLE WHERE SUB_SCOPE_ID_ = ? AND SCOPE_TYPE_ IN (?, ?)
Are these queries necessary for synchronous flows, or is there a way to optimize or eliminate them to reduce latency?
Also, I was under the impression that in purely synchronous execution, the engine could bypass runtime tables and directly write to history tables (when history is enabled). Is that understanding incorrect?