Interface ActivityHandle<R>

Type Parameters:
R - the result type of the activity
All Superinterfaces:
UntypedActivityHandle

@Experimental public interface ActivityHandle<R> extends UntypedActivityHandle
A typed handle to a standalone activity execution. Extends UntypedActivityHandle with typed result methods.

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

See Also:
  • Method Details

    • getResult

      R getResult()
      Blocks until the standalone activity completes and returns the typed result.
      Throws:
      ActivityFailedException - if the activity failed, timed out, or was cancelled
    • getResult

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

      CompletableFuture<R> getResultAsync()
      Returns a future that completes when the activity completes and resolves to the typed result.
    • getResultAsync

      CompletableFuture<R> getResultAsync(long timeout, TimeUnit unit)
      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
    • fromUntyped

      static <R> ActivityHandle<R> fromUntyped(UntypedActivityHandle handle, Class<R> resultClass)
      Wraps an UntypedActivityHandle with a known result type.
      Parameters:
      handle - the untyped handle to wrap
      resultClass - the class to deserialize the result into
      Returns:
      a typed handle
    • fromUntyped

      static <R> ActivityHandle<R> fromUntyped(UntypedActivityHandle handle, Class<R> resultClass, @Nullable Type resultType)
      Wraps an UntypedActivityHandle with a known result type for generic types.
      Parameters:
      handle - the untyped handle to wrap
      resultClass - the class to deserialize the result into
      resultType - the generic type; may be null
      Returns:
      a typed handle