Configuring child workflow options

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:

  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

Hello @walkercp

yes, same applies to child workflows. There is no different between both (childwokflows and workflows) beyond how they are triggered.

Passing it as an input to the parent workflow is a common approach, if you have it available when you start the parent workflow. Maybe you want to have a POJO to wrap the parameters

class WorkflowInput{
        DataInput input;
        ChildWorkflowOptionsJson childWorkflowOptions1;
        ChildWorkflowOptionsJson childWorkflowOptions2;

which will make adding new parameters easier.

If you have it stored anywhere, you can use a local activity to load the configuration.

Let me know if it helps,

thanks @antonio.perez appreciate the answer.