Recommended way for Signal implementation

  1. Is it ok to invoke async activity or workflow from a signal method? If yes, then how can the main workflow get the result of the async activity/workflow execution that has been invoked from a signal method.
  2. Also, is that ok if we invoke a cron workflow from a signal method?

Please suggest if there are any recommendations on signal implementation code.

  1. Yes. The main workflow can receive results by awaiting on fields of type Promise (or any other) that become ready upon the activity or child workflow completion.
  2. Yes, you can.
    Something like:
public class ParentWorkflowImpl implements ParentWorkflow {

  private final CompletablePromise<String> childCompletion = Workflow.newPromise();

  @Override
  public String executeParent() {
    return childCompletion.get();
  }

  @Override
  public void processSignal() {
    ChildWorkflow child = Workflow.newChildWorkflowStub(ChildWorkflow.class);
    childCompletion.completeFrom(Async.function(child::executeChild));
  }
}