Interface ActivityCompletionClient


public interface ActivityCompletionClient
Used to complete asynchronously activities that called ActivityExecutionContext.doNotCompleteOnReturn().

Use WorkflowClient.newActivityCompletionClient() to create an instance.

  • Method Details

    • complete

      <R> void complete(byte[] taskToken, R result) throws ActivityCompletionException
      Completes an activity execution successfully using a task token.

      This overload works with both workflow activities and standalone activities.

      Parameters:
      taskToken - token of the activity attempt to complete
      result - of the activity execution
      Throws:
      ActivityCompletionException
    • complete

      <R> void complete(String workflowId, Optional<String> runId, String activityId, R result) throws ActivityCompletionException
      Completes a workflow activity execution successfully using workflow and activity IDs.

      This overload is only for workflow activities. To complete a standalone activity by ID, use completeStandalone(String, Optional, Object).

      Parameters:
      workflowId - id of the workflow that started the activity
      runId - optional run id of the workflow that started the activity
      activityId - id of the activity
      result - of the activity execution
      Throws:
      ActivityCompletionException
    • completeStandalone

      <R> void completeStandalone(String activityId, Optional<String> activityRunId, R result) throws ActivityCompletionException
      Completes a standalone activity execution successfully using activity ID.

      This method is only for standalone activities. To complete a workflow activity by ID, use complete(String, Optional, String, Object).

      Parameters:
      activityId - id of the standalone activity
      activityRunId - optional run id of the standalone activity, or Optional.empty()
      result - of the activity execution
      Throws:
      ActivityCompletionException
    • completeExceptionally

      void completeExceptionally(byte[] taskToken, Exception result) throws ActivityCompletionException
      Completes an activity execution with failure using a task token.

      This overload works with both workflow activities and standalone activities.

      Parameters:
      taskToken - token of the activity attempt to complete
      result - the exception to be used as a failure details object
      Throws:
      ActivityCompletionException
    • completeExceptionally

      void completeExceptionally(String workflowId, Optional<String> runId, String activityId, Exception result) throws ActivityCompletionException
      Completes a workflow activity execution with failure using workflow and activity IDs.

      This overload is only for workflow activities. To complete a standalone activity by ID, use completeExceptionallyStandalone(String, Optional, Exception).

      Parameters:
      workflowId - id of the workflow that started the activity
      runId - optional run id of the workflow that started the activity
      activityId - id of the activity
      result - the exception to be used as a failure details object
      Throws:
      ActivityCompletionException
    • completeExceptionallyStandalone

      void completeExceptionallyStandalone(String activityId, Optional<String> activityRunId, Exception result) throws ActivityCompletionException
      Completes a standalone activity execution with failure using activity ID.

      This method is only for standalone activities. To complete a workflow activity by ID, use completeExceptionally(String, Optional, String, Exception).

      Parameters:
      activityId - id of the standalone activity
      activityRunId - optional run id of the standalone activity, or Optional.empty()
      result - the exception to be used as a failure details object
      Throws:
      ActivityCompletionException
    • reportCancellation

      <V> void reportCancellation(byte[] taskToken, V details) throws ActivityCompletionException
      Confirms successful cancellation to the server using a task token.

      This overload works with both workflow activities and standalone activities.

      Parameters:
      taskToken - token of the activity attempt
      details - details to record with the cancellation
      Throws:
      ActivityCompletionException
    • reportCancellation

      <V> void reportCancellation(String workflowId, Optional<String> runId, String activityId, V details) throws ActivityCompletionException
      Confirms successful cancellation of a workflow activity to the server using workflow and activity IDs.

      This overload is only for workflow activities. To cancel a standalone activity by ID, use reportCancellationStandalone(String, Optional, Object).

      Parameters:
      workflowId - id of the workflow that started the activity
      runId - optional run id of the workflow that started the activity
      activityId - id of the activity
      details - details to record with the cancellation
      Throws:
      ActivityCompletionException
    • reportCancellationStandalone

      <V> void reportCancellationStandalone(String activityId, Optional<String> activityRunId, V details) throws ActivityCompletionException
      Confirms successful cancellation of a standalone activity to the server using activity ID.

      This method is only for standalone activities. To cancel a workflow activity by ID, use reportCancellation(String, Optional, String, Object).

      Parameters:
      activityId - id of the standalone activity
      activityRunId - optional run id of the standalone activity, or Optional.empty()
      details - details to record with the cancellation
      Throws:
      ActivityCompletionException
    • heartbeat

      <V> void heartbeat(byte[] taskToken, V details) throws ActivityCompletionException
      Records a heartbeat for an activity using a task token.

      This overload works with both workflow activities and standalone activities.

      Parameters:
      taskToken - token of the activity attempt
      details - details to record with the heartbeat
      Throws:
      ActivityCompletionException - if activity should stop executing
    • heartbeat

      <V> void heartbeat(String workflowId, Optional<String> runId, String activityId, V details) throws ActivityCompletionException
      Records a heartbeat for a workflow activity using workflow and activity IDs.

      This overload is only for workflow activities. To heartbeat a standalone activity by ID, use heartbeatStandalone(String, Optional, Object).

      Parameters:
      workflowId - id of the workflow that started the activity
      runId - optional run id of the workflow that started the activity
      activityId - id of the activity
      details - details to record with the heartbeat
      Throws:
      ActivityCompletionException - if activity should stop executing
    • heartbeatStandalone

      <V> void heartbeatStandalone(String activityId, Optional<String> activityRunId, V details) throws ActivityCompletionException
      Records a heartbeat for a standalone activity using activity ID.

      This method is only for standalone activities. To heartbeat a workflow activity by ID, use heartbeat(String, Optional, String, Object).

      Parameters:
      activityId - id of the standalone activity
      activityRunId - optional run id of the standalone activity, or Optional.empty()
      details - details to record with the heartbeat
      Throws:
      ActivityCompletionException - if activity should stop executing
    • withContext

      Supply this context if correct serialization of activity heartbeats, results or other payloads requires DataConverter, PayloadConverter or PayloadCodec to be aware of ActivitySerializationContext.
      Parameters:
      context - provides information to the data converter about the abstraction the data belongs to
      Returns:
      an instance of DataConverter that may use the provided context for serialization
      See Also:
    • withContext

      @Experimental @Nonnull ActivityCompletionClient withContext(@Nonnull NexusSerializationContext context)
      Supply this context when completing a standalone activity started by a Nexus operation handler, so its result, failure and heartbeat details are encoded with the context the Nexus caller decodes them with. Get it from ActivityInfo.getNexusSerializationContext() and store it together with the task token.
      Parameters:
      context - the Nexus context of the operation handler that started the activity
      Returns:
      an instance of ActivityCompletionClient that uses the provided context for serialization
      See Also: