Cancel Workflows
Infinitic is still in active development. Subscribe here to follow its progress.
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:
HelloWorld helloworld = client.getWorkflowById(HelloWorld.class, id);
client.cancel(helloworld);
val helloworld: HelloWorld = client.getWorkflowById(HelloWorld::class.java, id)
client.cancel(helloworld)
or by tag:
HelloWorld helloworld = client.getWorkflowByTag(HelloWorld.class, "foo");
client.cancel(helloworld);
val helloworld: HelloWorld = client.getWorkflowByTag(HelloWorld::class.java, "foo")
client.cancel(helloworld)
Cancelling a workflow cancels its child workflows as well.
If you do not want this behavior, you should dispatch your child workflow from a task.
The direct cancellation of a child workflow will trigger a CanceledWorkflowException
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.