Interface ActivityClientCallsInterceptor
- All Known Implementing Classes:
ActivityClientCallsInterceptorBase,RootActivityClientInvoker
Intercepts calls to the
ActivityClient related to the lifecycle of a
standalone Activity.
Prefer extending ActivityClientCallsInterceptorBase and overriding only the methods
you need instead of implementing this interface directly. ActivityClientCallsInterceptorBase provides correct default implementations to all the methods
of this interface.
-
Nested Class Summary
Nested ClassesModifier and TypeInterfaceDescriptionstatic final classstatic final classstatic final classstatic final classstatic final classstatic final classstatic final classstatic final classstatic final classstatic final classstatic final classstatic final classstatic final classstatic final class -
Method Summary
Modifier and TypeMethodDescriptionRequests cooperative cancellation of a running standalone activity.Returns the count of activity executions matching the Visibility query ininput.Returns the current execution description for a standalone activity.Synchronously long-polls the server until the activity completes, then deserializes and returns the result.Asynchronously polls for the activity result without blocking the calling thread.Returns a lazyStreamof activity execution metadata matching the Visibility query ininput.Schedules a standalone activity for execution.Forcefully terminates a running standalone activity.
-
Method Details
-
startActivity
ActivityClientCallsInterceptor.StartActivityOutput startActivity(ActivityClientCallsInterceptor.StartActivityInput input) Schedules a standalone activity for execution. The activity type name, arguments, and scheduling options are carried ininput.- Parameters:
input- activity type, raw arguments, scheduling options, and propagated header- Returns:
- output containing the caller-supplied activity ID and the run ID assigned by the server (if the server provides one)
- Throws:
ActivityAlreadyStartedException- if an activity with the same ID is already running
-
getActivityResult
<R> ActivityClientCallsInterceptor.GetActivityResultOutput<R> getActivityResult(ActivityClientCallsInterceptor.GetActivityResultInput<R> input) throws TimeoutException Synchronously long-polls the server until the activity completes, then deserializes and returns the result. Loops automatically on empty long-poll responses (server-side timeout with no outcome yet). Blocks the calling thread for the duration.- Type Parameters:
R- the expected result type- Parameters:
input- activity ID, optional run ID, and result class and generic type- Returns:
- output wrapping the deserialized activity result
- Throws:
ActivityFailedException- if the activity failed or was cancelledTimeoutException
-
describeActivity
ActivityClientCallsInterceptor.DescribeActivityOutput describeActivity(ActivityClientCallsInterceptor.DescribeActivityInput input) Returns the current execution description for a standalone activity. If a long-poll token from a prior call is present ininput, the server blocks until the description changes or the poll times out, enabling efficient change detection.- Parameters:
input- activity ID, optional run ID, and optional long-poll token from a prior call- Returns:
- output containing the
ActivityExecutionDescription; the fresh long-poll token for the next call is stored inside the returnedActivityExecutionDescription
-
cancelActivity
ActivityClientCallsInterceptor.CancelActivityOutput cancelActivity(ActivityClientCallsInterceptor.CancelActivityInput input) Requests cooperative cancellation of a running standalone activity. The activity will receive a cancellation request on its next heartbeat; it may choose to honour or ignore it.- Parameters:
input- activity ID, optional run ID, and optional human-readable cancellation reason- Returns:
- an empty output object (reserved for future use)
-
terminateActivity
ActivityClientCallsInterceptor.TerminateActivityOutput terminateActivity(ActivityClientCallsInterceptor.TerminateActivityInput input) Forcefully terminates a running standalone activity. Unlike cancellation, termination is immediate and cannot be caught or suppressed by the activity.- Parameters:
input- activity ID, optional run ID, and optional human-readable termination reason- Returns:
- an empty output object (reserved for future use)
-
listActivities
ActivityClientCallsInterceptor.ListActivitiesOutput listActivities(ActivityClientCallsInterceptor.ListActivitiesInput input) Returns a lazyStreamof activity execution metadata matching the Visibility query ininput. Pages are fetched from the server on demand as the stream is consumed.- Parameters:
input- Visibility query string and listing options (e.g. page-size limit)- Returns:
- output wrapping a stream of
ActivityExecutionMetadata
-
countActivities
ActivityClientCallsInterceptor.CountActivitiesOutput countActivities(ActivityClientCallsInterceptor.CountActivitiesInput input) Returns the count of activity executions matching the Visibility query ininput.- Parameters:
input- Visibility query string and count options- Returns:
- output wrapping the
ActivityExecutionCount
-
getActivityResultAsync
<R> CompletableFuture<ActivityClientCallsInterceptor.GetActivityResultOutput<R>> getActivityResultAsync(ActivityClientCallsInterceptor.GetActivityResultInput<R> input) Asynchronously polls for the activity result without blocking the calling thread. Returns aCompletableFuturethat completes with the deserialized result when the activity succeeds, or completes exceptionally withActivityFailedExceptionon failure, orTimeoutExceptionif the deadline ininputexpires before the activity completes.The default implementation wraps
getActivityResult(io.temporal.common.interceptors.ActivityClientCallsInterceptor.GetActivityResultInput<R>)in aCompletableFuture.supplyAsync(java.util.function.Supplier<U>)call. Interceptors that want true non-blocking behavior should override this method.- Type Parameters:
R- the expected result type- Parameters:
input- activity ID, optional run ID, result class and generic type, and timeout- Returns:
- a future that completes with output wrapping the deserialized activity result
-