public interface ActivityExecutionContext
Activity.getExecutionContext()
from an activity implementation to access.Modifier and Type | Method and Description |
---|---|
void |
doNotCompleteOnReturn()
If this method is called during an activity execution then activity is not going to complete
when its method returns.
|
<V> java.util.Optional<V> |
getHeartbeatDetails(java.lang.Class<V> detailsClass)
Extracts heartbeat details from the last failed attempt.
|
<V> java.util.Optional<V> |
getHeartbeatDetails(java.lang.Class<V> detailsClass,
java.lang.reflect.Type detailsType)
Extracts heartbeat details from the last failed attempt.
|
ActivityInfo |
getInfo()
Information about activity invocation and the caller workflow
|
com.uber.m3.tally.Scope |
getMetricsScope() |
byte[] |
getTaskToken()
A correlation token that can be used to complete the activity asynchronously through
ActivityCompletionClient.complete(byte[], Object) . |
<V> void |
heartbeat(V details)
Use to notify Simple Workflow that activity execution is alive.
|
boolean |
isDoNotCompleteOnReturn() |
boolean |
isUseLocalManualCompletion()
Returns true if
useLocalManualCompletion() method has been called on this context. |
ActivityCompletionClient |
useLocalManualCompletion()
Local manual completion, sets
doNotCompleteOnReturn() flag making activity completion
asynchronous, also returns completion client. |
ActivityInfo getInfo()
<V> void heartbeat(V details) throws ActivityCompletionException
details
- In case of activity timeout details are returned as a field of the exception
thrown.ActivityCompletionException
- Indicates that activity cancellation was requested by the
workflow or any other reason for activity to stop execution. Should be rethrown from
activity implementation to indicate successful cancellation.<V> java.util.Optional<V> getHeartbeatDetails(java.lang.Class<V> detailsClass)
RetryOptions
on ActivityOptions
. If an
activity failed then the server would attempt to dispatch another activity task to retry
according to the retry options. If there was heartbeat details reported by the activity from
the failed attempt, the details would be delivered along with the activity task for the retry
attempt. The activity could extract the details by getHeartbeatDetails(Class)
() and
resume from the progress.detailsClass
- type of the heartbeat details<V> java.util.Optional<V> getHeartbeatDetails(java.lang.Class<V> detailsClass, java.lang.reflect.Type detailsType)
RetryOptions
on ActivityOptions
. If an
activity failed then the server would attempt to dispatch another activity task to retry
according to the retry options. If there was heartbeat details reported by the activity from
the failed attempt, the details would be delivered along with the activity task for the retry
attempt. The activity could extract the details by getHeartbeatDetails(Class)
() and
resume from the progress.detailsClass
- type of the heartbeat detailsbyte[] getTaskToken()
ActivityCompletionClient.complete(byte[], Object)
.void doNotCompleteOnReturn()
ActivityCompletionClient
. Note that async activities that have isUseLocalManualCompletion()
set to false would not respect the limit defined by WorkerOptions.getMaxConcurrentActivityExecutionSize()
. If you want to limit the number of
concurrent async activities and if you always complete those activities from the same activity
worker you should use useLocalManualCompletion()
instead.boolean isDoNotCompleteOnReturn()
boolean isUseLocalManualCompletion()
useLocalManualCompletion()
method has been called on this context. If
this flag is set to true, ActivityWorker
would not release
concurrency semaphore and delegate release function to the manual activity client returned by
useLocalManualCompletion()
ActivityCompletionClient useLocalManualCompletion()
doNotCompleteOnReturn()
flag making activity completion
asynchronous, also returns completion client. Returned completion client must be used to
complete the activity on the same machine. Main difference from calling doNotCompleteOnReturn()
directly is that by using this method maximum number of concurrent
activities defined by WorkerOptions.getMaxConcurrentActivityExecutionSize()
will be
respected. Users must be careful and always call completion method on the ActivityCompletionClient
otherwise activity worker could stop polling new work as it will
consider all activities that didn't explicitly finish as still running.com.uber.m3.tally.Scope getMetricsScope()