Interface WorkflowInfo


public interface WorkflowInfo
Provides information about the current Workflow Execution and Run. Also provides access to immutable information about connected entities like Parent Workflow Execution or a previous Run.
  • Method Details

    • getNamespace

      String getNamespace()
      Returns:
      Workflow Namespace
    • getWorkflowId

      String getWorkflowId()
      Returns:
      Workflow ID
    • getWorkflowType

      String getWorkflowType()
      Returns:
      Workflow Type
    • getRunId

      @Nonnull String getRunId()
      Note: RunId is unique identifier of one workflow code execution. Reset changes RunId.
      Returns:
      Workflow Run ID that is handled by the current workflow code execution.
      See Also:
    • getFirstExecutionRunId

      @Nonnull String getFirstExecutionRunId()
      Returns:
      The very first original RunId of the current Workflow Execution preserved along the chain of ContinueAsNew, Retry, Cron and Reset. Identifies the whole Runs chain of Workflow Execution.
    • getContinuedExecutionRunId

      Optional<String> getContinuedExecutionRunId()
      Returns:
      Run ID of the previous Workflow Run which continued-as-new or retried or cron-scheduled into the current Workflow Run.
    • getOriginalExecutionRunId

      @Nonnull String getOriginalExecutionRunId()
      Note: This value is NOT preserved by continue-as-new, retries or cron Runs. They are separate Runs of one Workflow Execution Chain.
      Returns:
      original RunId of the current Workflow Run. This value is preserved during Reset which changes RunID.
      See Also:
    • getTaskQueue

      String getTaskQueue()
      Returns:
      Workflow Task Queue name
    • getRetryOptions

      @Nullable RetryOptions getRetryOptions()
    • getWorkflowRunTimeout

      Duration getWorkflowRunTimeout()
      Returns:
      Timeout for a Workflow Run specified during Workflow start in WorkflowOptions.Builder.setWorkflowRunTimeout(Duration)
    • getWorkflowExecutionTimeout

      Duration getWorkflowExecutionTimeout()
      Returns:
      Timeout for the Workflow Execution specified during Workflow start in WorkflowOptions.Builder.setWorkflowExecutionTimeout(Duration)
    • getRunStartedTimestampMillis

      long getRunStartedTimestampMillis()
      The time workflow run has started. Note that this time can be different from the time workflow function started actual execution.
    • getSearchAttributes

      @Deprecated @Nullable io.temporal.api.common.v1.SearchAttributes getSearchAttributes()
      Deprecated.
      This method is used to get raw proto serialized Search Attributes.

      Consider using more user-friendly methods on Workflow class, including Workflow.getSearchAttributes(), Workflow.getSearchAttribute(String) or Workflow.getSearchAttributeValues(String) instead of this method to access deserialized search attributes.

      Returns:
      raw Search Attributes Protobuf entity, null if empty
    • getParentWorkflowId

      Optional<String> getParentWorkflowId()
      Returns:
      Workflow ID of the parent Workflow
    • getParentRunId

      Optional<String> getParentRunId()
      Returns:
      Run ID of the parent Workflow
    • getRootWorkflowId

      Optional<String> getRootWorkflowId()
      Returns:
      Workflow ID of the root Workflow

      Note: On server versions prior to v1.27.0, this method will be empty. Otherwise, it will be empty if the workflow is its own root.

    • getRootRunId

      Optional<String> getRootRunId()
      Returns:
      Run ID of the root Workflow

      Note: On server versions prior to v1.27.0, this method will be empty. Otherwise, it will be empty if the workflow is its own root.

    • getAttempt

      int getAttempt()
      Returns:
      Workflow retry attempt handled by this Workflow code execution. Starts on "1".
    • getCronSchedule

      String getCronSchedule()
      Returns:
      Workflow cron schedule
    • getHistoryLength

      long getHistoryLength()
      Returns:
      length of Workflow history up until the current moment of execution. This value changes during the lifetime of a Workflow Execution. You may use this information to decide when to call Workflow.continueAsNew(Object...).
    • getHistorySize

      long getHistorySize()
      Returns:
      size of Workflow history in bytes up until the current moment of execution. This value changes during the lifetime of a Workflow Execution.
    • isContinueAsNewSuggested

      boolean isContinueAsNewSuggested()
      Returns:
      true if the server is configured to suggest continue as new and it is suggested. This value changes during the lifetime of a Workflow Execution.
    • getSuggestContinueAsNewReasons

      @Experimental List<SuggestContinueAsNewReason> getSuggestContinueAsNewReasons()
      Returns:
      the reasons why continue-as-new is suggested, or an empty list if not suggested. This value changes during the lifetime of a Workflow Execution.
    • isTargetWorkerDeploymentVersionChanged

      @Experimental boolean isTargetWorkerDeploymentVersionChanged()
      Returns:
      true if the target worker deployment version has changed for this workflow since the last workflow task. This is only relevant for workflows using the PINNED versioning behavior. When true, the workflow may want to continue-as-new with ContinueAsNewOptions.Builder.setInitialVersioningBehavior(io.temporal.common.InitialVersioningBehavior) set to AUTO_UPGRADE.
    • getCurrentBuildId

      Optional<String> getCurrentBuildId()
      Returns:
      The Build ID of the worker which executed the current Workflow Task. May be empty the task was completed by a worker without a Build ID. If this worker is the one executing this task for the first time and has a Build ID set, then its ID will be used. This value may change over the lifetime of the workflow run, but is deterministic and safe to use for branching.
    • getPriority

      @Experimental @Nonnull Priority getPriority()
      Return the priority of the workflow task.

      Note: If unset or on an older server version, this method will return Priority.getDefaultInstance().