Interface UntypedActivityHandle

All Known Subinterfaces:
ActivityHandle<R>
All Known Implementing Classes:
ActivityHandleImpl

public interface UntypedActivityHandle
An untyped handle to a standalone activity execution. Use this to get the result, describe, cancel, or terminate the activity when the result type is not known at compile time.

Obtain an instance via ActivityClient.start(String, StartActivityOptions, Object...) or ActivityClient.getHandle(String, String).

See Also:
  • Method Details

    • getActivityId

      String getActivityId()
      The user-assigned activity ID.
    • getActivityRunId

      @Nullable String getActivityRunId()
      The server-assigned run ID for this execution. Present when the handle was returned by ActivityClient.start(java.lang.Class<I>, io.temporal.workflow.Functions.Proc1<I>, io.temporal.client.StartActivityOptions). May be null when obtained via ActivityClient.getHandle(String, String) with a null run ID — call describe() to retrieve the current run ID.
    • getResult

      <R> R getResult(Class<R> resultClass)
      Blocks until the standalone activity completes and returns the typed result. Polls the server via long-polling.
      Parameters:
      resultClass - the class to deserialize the result into
      Throws:
      ActivityFailedException - if the activity failed, timed out, or was cancelled
    • getResult

      <R> R getResult(Class<R> resultClass, @Nullable Type resultType)
      Blocks until the standalone activity completes and returns the typed result. Use this overload for generic return types (e.g. List<String>).
      Parameters:
      resultClass - the class to deserialize the result into
      resultType - the generic type to use for deserialization; may be null
      Throws:
      ActivityFailedException - if the activity failed, timed out, or was cancelled
    • getResult

      <R> R getResult(long timeout, TimeUnit unit, Class<R> resultClass) throws TimeoutException
      Blocks until the standalone activity completes and returns the typed result, or throws if the timeout expires before the activity completes.
      Parameters:
      timeout - maximum time to wait
      unit - unit of timeout
      resultClass - the class to deserialize the result into
      Throws:
      ActivityFailedException - if the activity failed, timed out on the server, or was cancelled
      TimeoutException - if the client-side timeout expires before the activity completes
    • getResult

      <R> R getResult(long timeout, TimeUnit unit, Class<R> resultClass, @Nullable Type resultType) throws TimeoutException
      Blocks until the standalone activity completes and returns the typed result, or throws if the timeout expires. Use this overload for generic return types (e.g. List<String>).
      Parameters:
      timeout - maximum time to wait
      unit - unit of timeout
      resultClass - the class to deserialize the result into
      resultType - the generic type to use for deserialization; may be null
      Throws:
      ActivityFailedException - if the activity failed, timed out on the server, or was cancelled
      TimeoutException - if the client-side timeout expires before the activity completes
    • getResultAsync

      <R> CompletableFuture<R> getResultAsync(Class<R> resultClass)
      Returns a future that completes when the activity completes and resolves to the typed result.
      Parameters:
      resultClass - the class to deserialize the result into
    • getResultAsync

      <R> CompletableFuture<R> getResultAsync(Class<R> resultClass, @Nullable Type resultType)
      Returns a future for generic return types (e.g. List<String>).
      Parameters:
      resultClass - the class to deserialize the result into
      resultType - the generic type to use for deserialization; may be null
    • getResultAsync

      <R> CompletableFuture<R> getResultAsync(long timeout, TimeUnit unit, Class<R> resultClass)
      Returns a future that completes when the activity completes, or fails with TimeoutException if the activity does not complete within the specified timeout.
      Parameters:
      timeout - maximum time to wait
      unit - unit of timeout
      resultClass - the class to deserialize the result into
    • getResultAsync

      <R> CompletableFuture<R> getResultAsync(long timeout, TimeUnit unit, Class<R> resultClass, @Nullable Type resultType)
      Returns a future for generic return types with a timeout.
      Parameters:
      timeout - maximum time to wait
      unit - unit of timeout
      resultClass - the class to deserialize the result into
      resultType - the generic type to use for deserialization; may be null
    • describe

      Describes the current state of the activity execution, without any of the payload-bearing fields. Equivalent to describe(DescribeActivityOptions.getDefaultInstance()).
      Returns:
      detailed information about the activity
    • describe

      Describes the current state of the activity execution.
      Parameters:
      options - which payload-bearing fields to include in the description. These are opt-in because they can be arbitrarily large.
      Returns:
      detailed information about the activity
    • cancel

      void cancel()
      Requests cancellation of the activity. The activity will receive a cancellation via ActivityExecutionContext.heartbeat(Object).
    • cancel

      void cancel(@Nullable String reason)
      Requests cancellation of the activity with an optional reason.
      Parameters:
      reason - human-readable reason for cancellation, may be null
    • terminate

      void terminate()
      Terminates the activity immediately, regardless of its current state.
    • terminate

      void terminate(@Nullable String reason)
      Terminates the activity immediately with a reason.
      Parameters:
      reason - human-readable reason for termination, may be null
    • pause

      @Experimental void pause()
      Pauses the activity. A paused activity stops being dispatched to workers until it is unpaused.
    • pause

      @Experimental void pause(PauseActivityOptions options)
      Pauses the activity with the given options.
      Parameters:
      options - pause options (reason)
    • unpause

      @Experimental void unpause()
      Unpauses the activity with default options, allowing it to be dispatched again.
    • unpause

      @Experimental void unpause(UnpauseActivityOptions options)
      Unpauses the activity with the given options.
      Parameters:
      options - unpause options (reason, jitter)
    • updateOptions

      Updates the activity's options. Only the options named by updates are changed; a derived field mask leaves the rest untouched. To revert to the options the activity was created with, use restoreOriginalOptions().

      Updates are created from the keys on ActivityOptionsUpdate, via ActivityOptionsUpdate.ActivityOptionsKey.set(T) to set an option or ActivityOptionsUpdate.ActivityOptionsKey.unset() to clear it.

      Each option may be named at most once; naming the same option twice throws IllegalArgumentException.

      Parameters:
      updates - the option updates to apply; at least one is required, and no option may be named more than once
      Returns:
      the activity options as resolved by the server after the update
      Throws:
      IllegalArgumentException - if updates is empty or names an option twice
    • restoreOriginalOptions

      @Experimental ActivityExecutionOptions restoreOriginalOptions()
      Restores the activity's options to the ones it was created with.
      Returns:
      the activity options as resolved by the server after the restore