I have a long-running workflow “Workflow1” from which I start a child workflow “Workflow2” (which is also a long-running workflow) in async.
I store the workflowId of the child workflow in the state of the parent workflow while starting the child workflow in async as shown below
I only want to expose the Parent workflow to the services.
To achieve this, we have exposed signal and query methods from the parent workflow, from which I need to call the child workflow’s signal/query method respectively.
I am able to call the signal method of child workflow from the signal method in parent workflow.
But not able to figure out a way to trigger the query method of a child workflow from the query method of the parent. Is this possible?
Note that if you have a concrete signal method handler define in your workflow interface it would be called for the associated signal, if not the dynamic one would.
But not able to figure out a way to trigger the query method of a child workflow from the query method of the parent. Is this possible?
Signal methods are executed inside workflow thread so in signal handler you could use ExternalWorkflowStub to signal the child if you wanted (which has the dynamic signal handler defined). This is not possible with query handlers however.
One thing you could consider is utilizing workflow id for parent/child so for example child workflow id could based on parent workflow id plus some known postfix so from the client perspective you would be able to signal/query child by just knowing the parent workflow id.
Is there any possibility of this being picked up for development at some point?
It would make the code in consuming services much more clean and elegant if there is a capability to Call Query Methods of external/child workflows from Query method of a Workflow.
Do agree that having to use activity to query external workflow from another workflow is not the most user friendly approach. Opened issue here, hope it helps.