Client
Cancel Running Workflows
The cancellation of a workflow stops its execution and delete its state.
We can cancel running workflows by using a stub that target them by id:
HelloWorkflow w =
client.getWorkflowById(HelloWorkflow.class, id);
client.cancel(w);
val w : HelloWorkflow =
client.getWorkflowById(HelloWorkflow::class.java, id)
client.cancel(w)
or by tag:
HelloWorkflow w =
client.getWorkflowByTag(HelloWorkflow.class, "foo");
client.cancel(w);
val w : HelloWorkflow =
client.getWorkflowByTag(HelloWorkflow::class.java, "foo")
client.cancel(w)
Cancelling a workflow cancels its child workflows as well.
If we do not want this behavior, we should dispatch our child workflow from a task.
The direct cancellation of a child workflow will trigger a WorkflowCanceledException
in the parent workflow if waiting for its completion.
The cancel
method waits for the adhoc message to be sent to Pulsar. If we prefer to not wait for this message to be sent, we can use the cancelAsync
method.