Childworkflow retry not workign

Hi there,

I’m trying a very simple child workflow example where a parent workflow spawns a child workflow which simply throws an exception. On spawning the child workflow I have set the retry policy to allow maximum 1 attempt.

However I have observed in the worker log that the worker keeps retrying on the child workflow. I’m new to temporal but would be great if someone can point me where I’m missing. Thanks a lot!

Here’s the parent workflow impl code. Note the retryOptions configuration:

public class ParentWorkflowImpl implements ParentWorkflow {

  @Override
  public void parentWorkflowMethod() {
    ChildWorkflowOptions options = ChildWorkflowOptions.newBuilder()
        .setWorkflowId("child-workflow-id")
        .setRetryOptions(RetryOptions.newBuilder()
            .setInitialInterval(Duration.ofSeconds(1))
            .setMaximumAttempts(1).build())
        .build();

    ChildWorkflow child = Workflow.newChildWorkflowStub(ChildWorkflow.class, options);
    try {
      child.childWorkflowMethod();
    } catch (ChildWorkflowFailure e) {
      System.err.println("Child Workflow failed with: " + e.getMessage());
      throw e;
    }
  }
}

Here’s the child workflow impl

public class ChildWorkflowImpl implements ChildWorkflow {
  @Override
  public void childWorkflowMethod() {
    throw new RuntimeException("Child workflow failed!");
  }
}

RuntimeException blocks workflow execution. This is done to support fixing bugs without losing workflows. Throw an ApplicationFailure from he child.

BTW failing workflows is rarely a good idea. Why do you plan to use it?

1 Like

Thanks Maxim! In fact I think this is very good point. I don’t have to fail my workflow. I just need to know the workflow execution result and do things accordingly.