Interface WorkflowInstanceOperator

All Known Subinterfaces:
WorkflowInstance, WorkflowInstances, WorkflowInstances.Single

public interface WorkflowInstanceOperator
Provides operations for requesting lifecycle changes to a workflow instance.

Cancellation is cooperative: a request does not forcibly terminate user code. Cancelling a step makes its pending result complete with a StepCancellationException. Cancelling a workflow wakes its execution, which then terminates with a WorkflowCancelledException. Workflow code can catch these signals to release resources, but should let cancellation continue rather than treating it as successful completion. User code that does not reach a framework-controlled cancellation point is not forcibly stopped.

Since:
5.4.0
Author:
Simon Zambrovski
  • Method Details

    • requestStepCancellation

      CompletableFuture<Boolean> requestStepCancellation(String stepName, @Nullable Throwable cause)
      Requests cooperative cancellation of one workflow step.
      Parameters:
      stepName - name of the step to cancel
      cause - optional reason for the cancellation
      Returns:
      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 step without terminating the workflow.
      Parameters:
      cause - optional reason for the cancellation
      Returns:
      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.
      Parameters:
      cause - optional reason for the cancellation
      Returns:
      future completing after the workflow cancellation event is durable and the workflow body was woken