Best practice for handling lost external events and resuming paused workflows

Hi,

This post shows how to start a child workflow async in Java, Best way to create an async child workflow , sample code here .

Something like this should work

ChildWorkflow child = Workflow.newChildWorkflowStub(ChildWorkflow.class, childWorkflowOptions);
Promise<String> result = Async.function(child::executeChild);
result.thenApply(
    (String r) -> {
      done = true;
      return r;
    });


Workflow.await(() -> done || signal_received);

You can put the logic within a cancellation scope to cancel the timer if the signal arrives first.

Another approach can be start the child workflow after the workflow await times out,

Workflow.await(duration, () -> sinal_received);

//child workflow polling  here

so you give time to kafka to send the signal back to the parent workflow

1 Like