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 the Activity Execution is not going
to complete when it's 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 the Activity Execution and the Workflow Execution that invoked it.
|
com.uber.m3.tally.Scope |
getMetricsScope() |
byte[] |
getTaskToken()
Gets a correlation token that can be used to complete the Activity Execution asynchronously
through
ActivityCompletionClient.complete(byte[], Object) . |
<V> void |
heartbeat(V details)
Used to notify the Workflow Execution that the Activity Execution is alive.
|
boolean |
isDoNotCompleteOnReturn() |
boolean |
isUseLocalManualCompletion()
Returns true if
useLocalManualCompletion() method has been called on this context. |
ManualActivityCompletionClient |
useLocalManualCompletion()
For local manual completion, sets the
doNotCompleteOnReturn() flag, making Activity
Execution completion asynchronous, and returns the completion client. |
ActivityInfo getInfo()
<V> void heartbeat(V details) throws ActivityCompletionException
details
- In case the Activity Execution times out details are returned as a field of the
exception that is thrown. The details are also accessible through getHeartbeatDetails(Class)
() on the next Activity Execution retry.ActivityCompletionException
- Which indicates that cancellation of the Activity Execution
was requested by the Workflow Execution. Or it could indicate any other reason for an
Activity Execution to stop. Should be rethrown from the Activity implementation to indicate
a successful cancellation.<V> java.util.Optional<V> getHeartbeatDetails(java.lang.Class<V> detailsClass)
RetryOptions
via ActivityOptions
. If an
Activity Execution failed then the server would attempt to dispatch another Activity Task to
retry the execution according to the retry options. If there were Heartbeat details reported by
the last Activity Execution that failed, they would be delivered along with the Activity Task
for the next retry attempt and can be extracted by the Activity implementation.detailsClass
- Class of the Heartbeat details<V> java.util.Optional<V> getHeartbeatDetails(java.lang.Class<V> detailsClass, java.lang.reflect.Type detailsType)
RetryOptions
via ActivityOptions
. If an
Activity Execution failed then the server would attempt to dispatch another Activity Task to
retry the execution according to the retry options. If there were Heartbeat details reported by
the last Activity Execution that failed, the details would be delivered along with the Activity
Task for the next retry attempt. The Activity implementation can extract the details via getHeartbeatDetails(Class)
() and resume progress.detailsClass
- Class of the Heartbeat detailsdetailsType
- Type of the Heartbeat detailsbyte[] getTaskToken()
ActivityCompletionClient.complete(byte[], Object)
.void doNotCompleteOnReturn()
ActivityCompletionClient
. Async Activity Executions 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 Activity Executions and if you always complete those Activity Executions with
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()
ManualActivityCompletionClient useLocalManualCompletion()
doNotCompleteOnReturn()
flag, making Activity
Execution completion asynchronous, and returns the completion client. Returned completion
client must be used to complete the Activity Execution on the same machine. The main difference
from calling doNotCompleteOnReturn()
directly is that by using this method the maximum
number of concurrent Activity Executions defined by WorkerOptions.getMaxConcurrentActivityExecutionSize()
will be respected. Users must be careful
and always call the completion method on the ManualActivityCompletionClient
otherwise
the Activity Worker could stop polling as it will consider all Activity Executions, that didn't
explicitly finish, as still running.com.uber.m3.tally.Scope getMetricsScope()