Failing Child workflow and Creating new child

Hi Maxim/Thiomir

I have a requirement, say I have three categories 1,2,3 only these 3 are configured and in future if some other value other than 1,2,3 is received in that case I wanted to throw an exception and mark my child workflow as failed and create new child in parallel to it. I have a parent workflow corresponding to this child which should be in running state while we are failing the child one, parent one should not fail.

In total I want to create a new child against the same parent on failure of previous child and state of parent should not be changed.


Hi, which Temporal SDK are you using?

Just to show sample with Java, you can define custom exceptions that when thrown would fail your child workflow execution:


In your child workflow code if you get invalid input could then throw MyCustomFailException and handle ChildWorkflowFailure in your parent workflow code and invoke child workflow again if needed.

Hi @tihomir,

Currently we are using temporal SDK version 1.16.0

And thanks for you quick reply we will try implementing the same you have explained.

Hi @tihomir,

Tried implementing the same as you have explained above, but by implementing this it’s behavior is like it failing the workflow task not the over all child workflow.

I am using Java and I have designed my application like this.

  1. I have a parent child relationship, one parent will be having one child
  2. In main method i am creating my worker, factory and invoking the factory start method there.
  3. I have assigned worker to ParentWorkflowImpl.class, not to ChildWorkflowImpl.class
  4. Now when i call the WorkflowClient.start of parent workflow it creates the parent workflow.
  5. Now from parent workflow method i am creating child options , getting child stub and invoking the child workflow method from parent workflow method.
  6. I have defined worker on parent workflow only not on child workflow but child is assigned with same worker as parent, did not encountered any problem with this implementation.

This is how I had implemented my app.

But I am not getting the result i wanted, i want to fail the workflow not workflow task.

If I had done something wrong please do guide me so that i can achieve my required functionality.