Interface ActivityCancellationToken


@Experimental public interface ActivityCancellationToken
Token that allows an Activity implementation to observe cancellation requests.
  • Field Details

  • Method Details

    • isCancellationRequested

      boolean isCancellationRequested()
      Returns true after cancellation has been requested for this Activity Execution.

      If this method returns true, the Activity implementation should stop its work and usually call throwIfCancellationRequested() to report successful cancellation to Temporal.

    • throwIfCancellationRequested

      void throwIfCancellationRequested() throws ActivityCanceledException
      Throws ActivityCanceledException if cancellation has been requested for this Activity Execution.

      Rethrowing this exception from Activity code reports successful cancellation to Temporal.

      Throws:
      ActivityCanceledException
    • getCancellationFuture

      CompletableFuture<Void> getCancellationFuture()
      Future that completes exceptionally with ActivityCanceledException when cancellation has been requested for this Activity Execution.

      Activity code should still call throwIfCancellationRequested() or otherwise report cancellation if it wants the Activity Execution to complete as canceled.