Starting Child workflow from Signal

Hi -

I have a set up which creates one parent workflow and then creates a child workflow from it.

Now I have a requirement to reset the child workflow on certain action(let us say an event). By the time action being performed , child workflow can be active or in completed state.

Solution I have done.

I am signalling Parent workflow on the event and in the signal , I am terminating child workflow if exists and re-creating the new child workflow . I have tested it seems working fine… Want to know if this is correct approach or is these any better way to solve the problem…

I am using java-sdk

Yes one way could be to terminate child workflow on signal (if you need to do cleanup you could cancel it instead) and then invoke the child workflow again.
If for some reason the number of these “resets” is super high for a single parent execution you might need to think about continueasnew to partition parent exec event history.

Another option could be to signal the child workflow directly and have it on signal call continueasnew in order to start new execution of this child workflow. To parent workflow it would seems as a single child execution.