Interface UntypedActivityHandle
- All Known Subinterfaces:
ActivityHandle<R>
- All Known Implementing Classes:
ActivityHandleImpl
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 Summary
Modifier and TypeMethodDescriptionvoidcancel()Requests cancellation of the activity.voidRequests cancellation of the activity with an optional reason.describe()Describes the current state of the activity execution.The user-assigned activity ID.The server-assigned run ID for this execution.<R> RBlocks until the standalone activity completes and returns the typed result, or throws if the timeout expires before the activity completes.<R> RBlocks until the standalone activity completes and returns the typed result, or throws if the timeout expires.<R> RBlocks until the standalone activity completes and returns the typed result.<R> RBlocks until the standalone activity completes and returns the typed result.<R> CompletableFuture<R> getResultAsync(long timeout, TimeUnit unit, Class<R> resultClass) Returns a future that completes when the activity completes, or fails withTimeoutExceptionif the activity does not complete within the specified timeout.<R> CompletableFuture<R> getResultAsync(long timeout, TimeUnit unit, Class<R> resultClass, Type resultType) Returns a future for generic return types with a timeout.<R> CompletableFuture<R> getResultAsync(Class<R> resultClass) Returns a future that completes when the activity completes and resolves to the typed result.<R> CompletableFuture<R> getResultAsync(Class<R> resultClass, Type resultType) Returns a future for generic return types (e.g.voidTerminates the activity immediately, regardless of its current state.voidTerminates the activity immediately with a reason.
-
Method Details
-
getActivityId
String getActivityId()The user-assigned activity ID. -
getActivityRunId
The server-assigned run ID for this execution. Present when the handle was returned byActivityClient.start(java.lang.Class<I>, io.temporal.workflow.Functions.Proc1<I>, io.temporal.client.StartActivityOptions). May benullwhen obtained viaActivityClient.getHandle(String, String)with anullrun ID — calldescribe()to retrieve the current run ID. -
getResult
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
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 intoresultType- the generic type to use for deserialization; may benull- Throws:
ActivityFailedException- if the activity failed, timed out, or was cancelled
-
getResult
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 waitunit- unit oftimeoutresultClass- the class to deserialize the result into- Throws:
ActivityFailedException- if the activity failed, timed out on the server, or was cancelledTimeoutException- if the client-sidetimeoutexpires 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 waitunit- unit oftimeoutresultClass- the class to deserialize the result intoresultType- the generic type to use for deserialization; may benull- Throws:
ActivityFailedException- if the activity failed, timed out on the server, or was cancelledTimeoutException- if the client-sidetimeoutexpires before the activity completes
-
getResultAsync
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
Returns a future for generic return types (e.g.List<String>).- Parameters:
resultClass- the class to deserialize the result intoresultType- the generic type to use for deserialization; may benull
-
getResultAsync
Returns a future that completes when the activity completes, or fails withTimeoutExceptionif the activity does not complete within the specified timeout.- Parameters:
timeout- maximum time to waitunit- unit oftimeoutresultClass- 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 waitunit- unit oftimeoutresultClass- the class to deserialize the result intoresultType- the generic type to use for deserialization; may benull
-
describe
ActivityExecutionDescription describe()Describes the current state of the activity execution.- Returns:
- detailed information about the activity
-
cancel
void cancel()Requests cancellation of the activity. The activity will receive a cancellation viaActivityExecutionContext.heartbeat(Object). -
cancel
Requests cancellation of the activity with an optional reason.- Parameters:
reason- human-readable reason for cancellation, may benull
-
terminate
void terminate()Terminates the activity immediately, regardless of its current state. -
terminate
Terminates the activity immediately with a reason.- Parameters:
reason- human-readable reason for termination, may benull
-