How can client know that a workflow is canceled?

When developing workflow, sometimes the client may cancel the workflow execution. I now know two ways to do that:

  1. use WorkflowStub.cancel()
  2. send a cancel signal, and inside the signal handler, i will cancel the cancellationScope and throw a CancelledFailure.
    My question is how can the client knows that a workflow is canceled. or i mean, finished its canceling logic and update its status to canceled or failed.
    Thanks.

The client can wait for the workflow result. When cancelled or failed, the exception will be thrown.

THanks! Will below implementation work?

WorkflowStub untyped = Workflow.NewUntypedStub(workflowId);
untyped.cancel();
String result = untyped.getResult(10, TimeUnit.SECONDS, String.class);

Yes, this code looks fine.