I making a PoC with temporal which include a main workflow which spawn a child workflow. I used the SAGA pattern to compensate the activities in the main workflow, but I’m wondering how I could compensate the activities in the child workflow.
Changing the ParentClosePolicy does not seem to have an impact on the child, as the child finish before the end of the parent workflow.
And as you cannot have several methods in a workflow, I can’t call a compensate method in the child workflow.
So I guess I have to write another child workflow for compensation which will try to erase any steps that may have be done by the first child workflow. And I would need to call this compensation workflow in the error handling of the main workflow.
If I understand correctly (in java), I have to launch the child workflow in async. And in the WorkflowMethod, I use Workflow.await(…) that will be triggered by a SignalMethod.
However if I need the return value of my child WorkflowMethod, I have to wait for the end of my main workflow to either commit or rollback the child workflow and then get the value of the Promise returned by the async child workflow method, once the child workflow get deblocked and end.
Am I wrong or is there another method to get a return value before the end of the child workflow ?