How to read variables in CALL ACTIVITY sub process in wait state?

I have a simple process that call a simple sub-process with an event-based gateway.
I use Spring RuntimeService.createProcessInstanceByKey.executeWithVariablesInReturn in order to start process. In returned variables I don’t find the variables created in sub-process because is in wait state. I view that variables only when sub-process ends.
How can I retrieve the sub-process variable? I have tried using createVariableInstanceQuery but I don’t think that is the corret way to do that. There are some best practices or clean operation I can use? What is the correct way to communicate from sub-process in wait state and super-process?

Hi @sc_camunda,
Welcome to our forum!

The Variable Instance Query is actually the right approach. This is useful if you want to ask for variables as long your call activity is being executed. Once finished you can also map needed variables back to the parent instance. See in Modeler at the tab Variables on you Call Activity.

Best, McAlm