Interface ActivityExecutionContext

    • Method Detail

      • getInfo

        ActivityInfo getInfo()
        Information about the Activity Execution and the Workflow Execution that invoked it.
      • heartbeat

        <V> void heartbeat​(V details)
                    throws ActivityCompletionException
        Used to notify the Workflow Execution that the Activity Execution is alive.
        Parameters:
        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.
        Throws:
        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.
      • getHeartbeatDetails

        <V> java.util.Optional<V> getHeartbeatDetails​(java.lang.Class<V> detailsClass)
        Extracts Heartbeat details from the last failed attempt. This is used in combination with retry options. An Activity Execution could be scheduled with optional 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.
        Parameters:
        detailsClass - Class of the Heartbeat details
      • getHeartbeatDetails

        <V> java.util.Optional<V> getHeartbeatDetails​(java.lang.Class<V> detailsClass,
                                                      java.lang.reflect.Type detailsGenericType)
        Extracts Heartbeat details from the last failed attempt. This is used in combination with retry options. An Activity Execution could be scheduled with optional 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.
        Parameters:
        detailsClass - Class of the Heartbeat details
        detailsGenericType - Type of the Heartbeat details
      • isDoNotCompleteOnReturn

        boolean isDoNotCompleteOnReturn()
        Returns:
        true if doNotCompleteOnReturn() was called and supported by the activity type, false otherwise
      • isUseLocalManualCompletion

        boolean isUseLocalManualCompletion()
        Returns:
        true if 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()
      • useLocalManualCompletion

        ManualActivityCompletionClient useLocalManualCompletion()
        For local manual completion, sets the doNotCompleteOnReturn() flag, making Activity Execution completion asynchronous, and returns the completion client. Returned completion client must be used to complete the Activity Execution inside the same Java process.

        The completion client returned from this method updates the Worker's Active Activity Executions Counter. This way the limit of concurrent Activity Executions defined by WorkerOptions.Builder.setMaxConcurrentActivityExecutionSize(int) is respected. It's the main difference of this method from calling doNotCompleteOnReturn().

        Always call one of the completion methods on the obtained completion client. Otherwise, an Activity Worker could stop polling as it will consider Activity Executions that wasn't explicitly completed as still running.

      • getMetricsScope

        com.uber.m3.tally.Scope getMetricsScope()
        Get scope for reporting business metrics in activity logic. This scope is tagged with a workflow and an activity type.

        The original metrics scope is set through WorkflowServiceStubsOptions.Builder.setMetricsScope(Scope) when a worker starts up.