humblefool
humblefool

Reputation: 3

How can i restart a parent workflow from child workflow or can i re-trigger within the parent workflow itself? - Cadence/ Temporal

I have a workflow with multiple activities 1,2,3...6 and if my workflow fail after activity 3 for one particular exception I'm planning to start a child workflow which will eventually fix the exception. After that I want to retry the parent workflow to finish the complete flow.

What can i use in the child workflow to achieve the above scenario?

I tried looking into the Workflow interface which has ContinueAsNew which will create it as a new workflow and perform all the activities again.

Upvotes: 0

Views: 576

Answers (1)

Maxim Fateev
Maxim Fateev

Reputation: 6890

I would recommend not failing the workflow, but implement the compensation and retry logic as part of it. You can write something like:

activities.a1(...);
activities.a2(...);
try {
   activities.a3(...);
} catch (MyParticularException e) {
   childWorklfow.fixExceptionIn3(...);
}
activities.a4(...);
activities.a5(...);
activities.a6(...);
activities.a7(...);

The idea of retrying the whole workflow comes from the synchronous request-reply world and almost never makes sense for workflows.

Upvotes: 1

Related Questions