Hi all,
I have a parent workflow which will spawn a couple of child workflows. I want to define the child workflow options based on external configuration and I’m looking to understand the correct approach to pass them in to the parent workflow.
I understand that workflow implementations generally should not have constructors to preserve determinism, would this still be the case even for child workflow options?
The approach I have taken for now is passing the options as inputs to the workflow method (using my own serializable form).
What would be the best practise method of doing this?
Is there any way to do it without defining my own serializable type?
A simplified example of the current approach (where .toTemporalNativeType() just maps the values to the actual temporal ChildWorkflowOptions type.) would look like this:
@Override
public void myParentWorkflowMethod(ChildWorkflowOptionsJson childWorkflowOptions1, ChildWorkflowOptionsJson childWorkflowOptions2) {
HelloChildWorkflow helloChildWorkflow = Workflow.newChildWorkflowStub( HelloChildWorkflow.class, childWorkflowOptions1.toTemporalNativeType());
GoodbyeChildWorkflow goodbyeChildWorkflow = Workflow.newChildWorkflowStub( GoodbyeChildWorkflow.class, childWorkflowOptions2.toTemporalNativeType());
//kick off child workflows
}
Many thanks
Craig