Interface WorkflowState

All Superinterfaces:
DescribableComponent
All Known Implementing Classes:
EventSourcedWorkflowState

public interface WorkflowState extends DescribableComponent
State of a workflow execution.

A WorkflowState returned by the Workflow Manager is a detached state value. Internal execution state may use the same contract while changing as workflow events are applied.

Since:
5.4.0
Author:
Simon Zambrovski
  • Method Details

    • workflowId

      String workflowId()
      Returns the unique workflow execution identifier.
      Returns:
      workflow identifier
    • workflowDefinitionId

      VersionedType workflowDefinitionId()
      Returns the workflow definition identity, including its current definition version.

      Use VersionedType.version() to obtain the definition version.

      Returns:
      workflow definition identity
    • workflowStepNames

      List<String> workflowStepNames()
      Retrieves a list of step names in the workflow execution.
      Returns:
      list of step names
    • getStep

      @Nullable WorkflowStep getStep(String stepName)
      Retrieves a step by name.
      Parameters:
      stepName - name of the step
      Returns:
      workflow step
    • containsStep

      boolean containsStep(String stepName)
      Checks if a step with the given name exists in the workflow execution.
      Parameters:
      stepName - name of the step
      Returns:
      true if the step exists, false otherwise
    • workflowStatus

      WorkflowStatus workflowStatus()
      Returns the status of the workflow execution.
      Returns:
      workflow status
    • payload

      Map<String,@Nullable Object> payload()
      Retrieves the payload of the workflow execution.
      Returns:
      payload of the workflow execution
    • versionFor

      String versionFor(String changeId)
      Returns the effective version for the given changeId.

      The effective version is the recorded version-migration string when a migration step has been projected for the change. Otherwise, it is workflowDefinitionId()'s version. This fallback is implicit, so workflows that have never executed a ctx.migrateVersion(changeId, newVersion) call carry no version-migration step in their event history.

      Parameters:
      changeId - the change identifier to query
      Returns:
      effective version for the change
    • hasVersionMigrationStep

      boolean hasVersionMigrationStep(String changeId)
      Returns true iff a migration step has been projected into state for the given changeId.

      Used by the migration primitive to distinguish "no recorded step, using the definition identity's version" from "an explicit migration step at the effective version". Only the former permits a new step to be written for a different version number.

      Parameters:
      changeId - the change identifier to query
      Returns:
      true iff a migration step was recorded for this changeId
    • versionMigrations

      Map<String,String> versionMigrations()
      Returns the recorded version migrations by change identifier.
      Returns:
      immutable map of recorded version migrations
    • throwTerminalCause

      void throwTerminalCause()
      Guards against invoking any primitive when the workflow has already reached a terminal state. Rethrows the original termination cause wrapped in the appropriate exception type.