Class ActivityHandleImpl
java.lang.Object
io.temporal.internal.client.ActivityHandleImpl
- All Implemented Interfaces:
UntypedActivityHandle
Implementation of
UntypedActivityHandle that delegates lifecycle operations through the
interceptor chain.-
Constructor Summary
ConstructorsConstructorDescriptionActivityHandleImpl(String activityId, String activityRunId, ActivityClientCallsInterceptor clientCallsInterceptor) -
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.
-
Constructor Details
-
ActivityHandleImpl
public ActivityHandleImpl(String activityId, @Nullable String activityRunId, ActivityClientCallsInterceptor clientCallsInterceptor)
-
-
Method Details
-
getActivityId
Description copied from interface:UntypedActivityHandleThe user-assigned activity ID.- Specified by:
getActivityIdin interfaceUntypedActivityHandle
-
getActivityRunId
Description copied from interface:UntypedActivityHandleThe 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 — callUntypedActivityHandle.describe()to retrieve the current run ID.- Specified by:
getActivityRunIdin interfaceUntypedActivityHandle
-
getResult
Description copied from interface:UntypedActivityHandleBlocks until the standalone activity completes and returns the typed result. Polls the server via long-polling.- Specified by:
getResultin interfaceUntypedActivityHandle- Parameters:
resultClass- the class to deserialize the result into
-
getResult
Description copied from interface:UntypedActivityHandleBlocks until the standalone activity completes and returns the typed result. Use this overload for generic return types (e.g.List<String>).- Specified by:
getResultin interfaceUntypedActivityHandle- Parameters:
resultClass- the class to deserialize the result intoresultType- the generic type to use for deserialization; may benull
-
getResult
Description copied from interface:UntypedActivityHandleBlocks until the standalone activity completes and returns the typed result, or throws if the timeout expires before the activity completes.- Specified by:
getResultin interfaceUntypedActivityHandle- Parameters:
timeout- maximum time to waitunit- unit oftimeoutresultClass- the class to deserialize the result into- Throws:
TimeoutException- if the client-sidetimeoutexpires before the activity completes
-
getResult
public <R> R getResult(long timeout, TimeUnit unit, Class<R> resultClass, @Nullable Type resultType) throws TimeoutException Description copied from interface:UntypedActivityHandleBlocks 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>).- Specified by:
getResultin interfaceUntypedActivityHandle- 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:
TimeoutException- if the client-sidetimeoutexpires before the activity completes
-
getResultAsync
Description copied from interface:UntypedActivityHandleReturns a future that completes when the activity completes and resolves to the typed result.- Specified by:
getResultAsyncin interfaceUntypedActivityHandle- Parameters:
resultClass- the class to deserialize the result into
-
getResultAsync
Description copied from interface:UntypedActivityHandleReturns a future for generic return types (e.g.List<String>).- Specified by:
getResultAsyncin interfaceUntypedActivityHandle- Parameters:
resultClass- the class to deserialize the result intoresultType- the generic type to use for deserialization; may benull
-
getResultAsync
Description copied from interface:UntypedActivityHandleReturns a future that completes when the activity completes, or fails withTimeoutExceptionif the activity does not complete within the specified timeout.- Specified by:
getResultAsyncin interfaceUntypedActivityHandle- Parameters:
timeout- maximum time to waitunit- unit oftimeoutresultClass- the class to deserialize the result into
-
getResultAsync
public <R> CompletableFuture<R> getResultAsync(long timeout, TimeUnit unit, Class<R> resultClass, @Nullable Type resultType) Description copied from interface:UntypedActivityHandleReturns a future for generic return types with a timeout.- Specified by:
getResultAsyncin interfaceUntypedActivityHandle- 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
Description copied from interface:UntypedActivityHandleDescribes the current state of the activity execution.- Specified by:
describein interfaceUntypedActivityHandle- Returns:
- detailed information about the activity
-
cancel
public void cancel()Description copied from interface:UntypedActivityHandleRequests cancellation of the activity. The activity will receive a cancellation viaActivityExecutionContext.heartbeat(Object).- Specified by:
cancelin interfaceUntypedActivityHandle
-
cancel
Description copied from interface:UntypedActivityHandleRequests cancellation of the activity with an optional reason.- Specified by:
cancelin interfaceUntypedActivityHandle- Parameters:
reason- human-readable reason for cancellation, may benull
-
terminate
public void terminate()Description copied from interface:UntypedActivityHandleTerminates the activity immediately, regardless of its current state.- Specified by:
terminatein interfaceUntypedActivityHandle
-
terminate
Description copied from interface:UntypedActivityHandleTerminates the activity immediately with a reason.- Specified by:
terminatein interfaceUntypedActivityHandle- Parameters:
reason- human-readable reason for termination, may benull
-