Failure propagation from Async Child workflow to Parent

Hi Team,

I have below scenario:

  1. Start a workflow
  2. Call child workflow(with 2 activities) asynchronously and Wait for signal from child workflow’s activity1
  3. Child workflow finishes activity 1, signals parent workflow to continue
  4. Child workflow now continues with activity 2 while parent workflow continues with its execution

I am able to implement the same, but the issue is when activity 1 in child workflow throws a Application Failure, the same is not getting propagated to parent workflow at all.

Could you please let me know how the failure can be propagated to parent here. Any ref impls will help too.

Hi @Prats

I am able to implement the same, but the issue is when activity 1 in child workflow throws a Application Failure, the same is not getting propagated to parent workflow at all.

I don’t think it will unless you fail the child workflow and wait in parent for the child workflow to complete/fail.

Given your implementation I think you can:

  • catch the application failure thrown by activity1 (note that depending on your activity options the activity might retry if application failure is retryable)
  • signal the parent workflow, to let it know the activity1 has failed.
  • rethrown the exception thrown by activity1 if you want to fail the child workflow

Let me know if it helps.
Antonio

Thanks for replying Antonio.
I did try signalling the failure and then re throwing it, but in that case saga methods are not getting called correctly. The async workflow’s saga compensation doesn’t get called.

Anyways, I had similar use case for activities as well.

  1. Call a long running activity asynchronously
  2. Block parent until signal is received from this activity
  3. Once signalled, proceed with other tasks

Here its the same again, if the async activity fails then parent is getting blocked waiting for the signal and eventually fails only when the heartbeat timeout occurs. But we would like to fail the workflow with correct failure and not the timeout that happened because of it.

Could you please let me know if there is any way of accomplishing this.

It looks like you want to wait for both the activity result and the signal. One way to achieve that would be by using the Await function:

  Workflow.await(()->signalReceived || activityPromise.isReady());
1 Like

Thanks Maxim, it worked :slight_smile:

Workflow.await(
() → isComplete || !StringUtils.isNotEmpty(wlPromise.get()));

Success case, it now waits for signal.
Failure case, exception gets propagated to parent workflow.

I wouldn’t call Promise.get() inside the Await condition. It is expected to be short running. I think you want

Workflow.await(() → isComplete || wlPromise.isReady());

Thanks for your time, Maxim.

But there is no isReady().

We only have these methods and thats why I tried get().

Should I use getFailure() or anything else?

Sorry, it is called isCompleted():

Workflow.await(() → isComplete || wlPromise.isCompleted());