Example of accessing parent objects from child


I have a Parent workflow which creates 100 childworkflows. Is there any way to access the objects in parent workflow either by querying it from the child. Any example would be appreciated. Thanks

In your child workflows you can get the parent workflow Id via:

Optional<String> parentId = Workflow.getInfo().getParentWorkflowId();

you can signal via ExternalWorkflowStub, but not query, so you would need to query via an activity in your child workflow. You can pass this parent workflow id as activity input and the activity would need to use WorkflowClient to create the workflow stub, query the parent and return the result.

Another option could be to have the parent signal the child workflows upon reaching a certain state.

If you would like a sample please open issue in java sdk samples repo for it. Thanks!