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 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
ActivityExecutionContext.useLocalManualCompletion() method has been called on this context. |
ManualActivityCompletionClient |
useLocalManualCompletion()
Local manual completion, sets
ActivityExecutionContext.doNotCompleteOnReturn() flag making activity completion
asynchronous, also returns 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 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.public <V> java.util.Optional<V> getHeartbeatDetails(java.lang.Class<V> detailsClass)
ActivityExecutionContext
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 ActivityExecutionContext.getHeartbeatDetails(Class)
() and
resume from the progress.getHeartbeatDetails
in interface ActivityExecutionContext
detailsClass
- type of the heartbeat detailspublic <V> java.util.Optional<V> getHeartbeatDetails(java.lang.Class<V> detailsClass, java.lang.reflect.Type detailsType)
ActivityExecutionContext
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 ActivityExecutionContext.getHeartbeatDetails(Class)
() and
resume from the progress.getHeartbeatDetails
in interface ActivityExecutionContext
detailsClass
- type of the heartbeat detailspublic byte[] getTaskToken()
ActivityExecutionContext
ActivityCompletionClient.complete(byte[], Object)
.getTaskToken
in interface ActivityExecutionContext
public void doNotCompleteOnReturn()
ActivityExecutionContext
ActivityCompletionClient
. Note that async activities 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 activities and if you always complete those activities from 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 completion
asynchronous, also returns completion client. Returned completion client must be used to
complete the activity on the same machine. Main difference from calling ActivityExecutionContext.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 ManualActivityCompletionClient
otherwise activity worker could stop polling new work as it
will consider all activities that didn't explicitly finish as still running.useLocalManualCompletion
in interface ActivityExecutionContext
public com.uber.m3.tally.Scope getMetricsScope()
getMetricsScope
in interface ActivityExecutionContext