public class ActivityExecutionContextBase extends java.lang.Object implements ActivityExecutionContext
Constructor and Description |
---|
ActivityExecutionContextBase(ActivityExecutionContext next) |
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
ActivityExecutionContext.useLocalManualCompletion() method has been called on this context. |
ManualActivityCompletionClient |
useLocalManualCompletion()
For local manual completion, sets the
ActivityExecutionContext.doNotCompleteOnReturn() flag, making Activity
Execution completion asynchronous, and returns the completion client. |
public ActivityExecutionContextBase(ActivityExecutionContext next)
public ActivityInfo getInfo()
ActivityExecutionContext
getInfo
in interface ActivityExecutionContext
public <V> void heartbeat(V details) throws ActivityCompletionException
ActivityExecutionContext
heartbeat
in interface ActivityExecutionContext
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 ActivityExecutionContext.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.public <V> java.util.Optional<V> getHeartbeatDetails(java.lang.Class<V> detailsClass)
ActivityExecutionContext
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.getHeartbeatDetails
in interface ActivityExecutionContext
detailsClass
- Class of the Heartbeat detailspublic <V> java.util.Optional<V> getHeartbeatDetails(java.lang.Class<V> detailsClass, java.lang.reflect.Type detailsType)
ActivityExecutionContext
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 ActivityExecutionContext.getHeartbeatDetails(Class)
() and resume progress.getHeartbeatDetails
in interface ActivityExecutionContext
detailsClass
- Class of the Heartbeat detailsdetailsType
- Type of the Heartbeat detailspublic byte[] getTaskToken()
ActivityExecutionContext
ActivityCompletionClient.complete(byte[], Object)
.getTaskToken
in interface ActivityExecutionContext
public void doNotCompleteOnReturn()
ActivityExecutionContext
ActivityCompletionClient
. Async Activity Executions that have ActivityExecutionContext.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 ActivityExecutionContext.useLocalManualCompletion()
instead.doNotCompleteOnReturn
in interface ActivityExecutionContext
public boolean isDoNotCompleteOnReturn()
isDoNotCompleteOnReturn
in interface ActivityExecutionContext
public boolean isUseLocalManualCompletion()
ActivityExecutionContext
ActivityExecutionContext.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
ActivityExecutionContext.useLocalManualCompletion()
isUseLocalManualCompletion
in interface ActivityExecutionContext
public ManualActivityCompletionClient useLocalManualCompletion()
ActivityExecutionContext
ActivityExecutionContext.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 ActivityExecutionContext.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.useLocalManualCompletion
in interface ActivityExecutionContext
public com.uber.m3.tally.Scope getMetricsScope()
getMetricsScope
in interface ActivityExecutionContext