Interface WorkflowCancellation

All Known Subinterfaces:
WorkflowCancellation.Request

@Internal public interface WorkflowCancellation
Coordinates cancellation requests for one running workflow instance.

Cancellation is requested from arbitrary threads but executed by the workflow control thread. This preserves the single-consumer ordering of workflow tasks and ensures that a completed future is followed by the appropriate durable terminal event before the returned future completes. This differs from WorkflowLifecycleControl, whose operations apply lifecycle commands synchronously on the workflow control thread.

Since:
5.4.0
Author:
Simon Zambrovski, Stefan Dragisic
  • Method Details

    • requestStepCancellation

      CompletableFuture<Boolean> requestStepCancellation(String stepName, @Nullable Throwable cause)
      Requests cooperative cancellation of one running workflow step.
      Parameters:
      stepName - name of the step to cancel
      cause - optional reason for the cancellation
      Returns:
      a future completing with true when a terminal step cancellation was recorded, or false when the step was unknown or already terminal
    • requestCancellationOfAllSteps

      CompletableFuture<Integer> requestCancellationOfAllSteps(@Nullable Throwable cause)
      Requests cooperative cancellation of every currently-running workflow step without terminating the workflow.
      Parameters:
      cause - optional reason for the cancellation
      Returns:
      a future completing with the number of steps for which terminal cancellation was recorded
    • requestWorkflowCancellation

      CompletableFuture<Void> requestWorkflowCancellation(@Nullable Throwable cause)
      Requests cancellation of the workflow and its local execution.
      Parameters:
      cause - optional reason for the cancellation
      Returns:
      a future completing after the workflow cancellation event is durable and the workflow body was woken