Class StateBasedWorkflowStepResult

java.lang.Object
io.axoniq.framework.workflow.runtime.execution.StateBasedWorkflowStepResult
All Implemented Interfaces:
WorkflowStepResult

@Internal public class StateBasedWorkflowStepResult extends Object implements WorkflowStepResult
Workflow Step result based on the Workflow State.
Since:
5.4.0
Author:
Allard Buijze, Stefan Dragisic, Simon Zambrovski
  • Constructor Details

    • StateBasedWorkflowStepResult

      public StateBasedWorkflowStepResult(String stepName, StateBasedWorkflowStepResult.StateChangeTrigger stateChangeTrigger, Consumer<Throwable> cancellation, WorkflowExecution state)
      Creates a result backed by the current workflow execution state.
      Parameters:
      stepName - step represented by this result
      stateChangeTrigger - operation that waits for the next state change
      cancellation - operation that requests cancellation of this step
      state - workflow execution providing the state
  • Method Details

    • getStepName

      public String getStepName()
      Specified by:
      getStepName in interface WorkflowStepResult
    • isCompleted

      public boolean isCompleted()
      Description copied from interface: WorkflowStepResult
      Check (non-blocking) if the step has finished (reached a terminal state).
      Specified by:
      isCompleted in interface WorkflowStepResult
      Returns:
      true, if the state is terminal.
    • result

      public Optional<Map<String,@Nullable Object>> result()
      Description copied from interface: WorkflowStepResult
      Retrieves optional result.
      Specified by:
      result in interface WorkflowStepResult
      Returns:
      result if the step has finished with a success. Will return empty optional, if the step is not finished.
    • resultAs

      public <T> Optional<T> resultAs(Type type)
      Description copied from interface: WorkflowStepResult
      Retrieves an optional result as a specific type.
      Specified by:
      resultAs in interface WorkflowStepResult
      Type Parameters:
      T - the type of the result
      Parameters:
      type - the type to convert the result to
      Returns:
      result if the step has finished with a success. Will return empty optional, if the step is not finished
    • resultAs

      public <T> Optional<T> resultAs(Type type, Converter converter)
      Description copied from interface: WorkflowStepResult
      Retrieves an optional result as a specific type.
      Specified by:
      resultAs in interface WorkflowStepResult
      Parameters:
      type - the type to convert the result to
      Returns:
      result if the step has finished with a success. Will return empty optional, if the step is not finished
    • error

      public Optional<StepFailedException> error()
      Description copied from interface: WorkflowStepResult
      Retrieves an optional error.
      Specified by:
      error in interface WorkflowStepResult
      Returns:
      error if the step has finished with an error. Will return empty optional, if the step is not finished
    • success

      public boolean success()
      Description copied from interface: WorkflowStepResult
      Blocks until step execution reaches a terminal state.
      Specified by:
      success in interface WorkflowStepResult
      Returns:
      true, if the operation completed successfully
    • failure

      public boolean failure()
      Description copied from interface: WorkflowStepResult
      Blocks until step execution reaches a terminal state.
      Specified by:
      failure in interface WorkflowStepResult
      Returns:
      true, if the operation completed with an exception
    • canceled

      public boolean canceled()
      Description copied from interface: WorkflowStepResult
      Blocks until step execution reaches a terminal state.
      Specified by:
      canceled in interface WorkflowStepResult
      Returns:
      true, if the operation was interrupted by an external party
    • timeout

      public boolean timeout()
      Description copied from interface: WorkflowStepResult
      Blocks until step execution reaches a terminal state.
      Specified by:
      timeout in interface WorkflowStepResult
      Returns:
      true, if the operation was interrupted by timeout specified on start
    • await

      public void await()
      Description copied from interface: WorkflowStepResult
      Blocks until step execution reaches a terminal state.
      Specified by:
      await in interface WorkflowStepResult
    • cancel

      public void cancel()
      Description copied from interface: WorkflowStepResult
      Cancels this step if it is still running. No-op if already in a terminal state.
      Specified by:
      cancel in interface WorkflowStepResult
    • cancel

      public void cancel(String reason)
      Description copied from interface: WorkflowStepResult
      Cancels this step with a reason if it is still running. No-op if already in a terminal state.
      Specified by:
      cancel in interface WorkflowStepResult
      Parameters:
      reason - human-readable cancellation reason.