Enum Class StepDurability

java.lang.Object
java.lang.Enum<StepDurability>
io.superdurable.dex.StepDurability
All Implemented Interfaces:
Serializable, Comparable<StepDurability>, Constable

public enum StepDurability extends Enum<StepDurability>
Selects when Dex durably records a Step method result relative to subsequent Flow work.

ASYNC lets Dex continue the Flow without first waiting for the completed method result to be persisted. This lowers the latency between Steps and lets the server batch persistence work, which generally provides higher throughput. The tradeoff is a small failure window: if the result has not yet been persisted when the underlying process or workflow engine fails, Dex may not see that completion during recovery and may invoke the already-completed Step method again. Step methods must therefore be idempotent regardless of the selected durability.

SYNC waits for the method result to be durably recorded before Dex advances based on that result. It adds persistence latency and prevents the same degree of server-side batching, but it closes the asynchronous result-loss window. It does not provide exactly-once execution, so Step methods must still be safe to retry.

The server default for Step methods is SYNC. Use FlowConfig.Builder.stepDurability to override the default for a Flow. Use StepOptions.Builder.waitForDurability or StepOptions.Builder.executeDurability to override one method on a specific Step; these method-level choices take precedence over the Flow configuration.

Wait-for and execute failure policies do not change this precedence. A Flow-wide asynchronous default therefore applies to methods with failure policies unless the Step method overrides it.

FlowConfig fastByDefault = FlowConfig.newBuilder()
        .stepDurability(StepDurability.ASYNC)
        .build();

public StepOptions getStepOptions() {
    return StepOptions.newBuilder()
            .waitForFailure(WaitForFailurePolicy.PROCEED)
            .waitForDurability(StepDurability.SYNC)
            .executeDurability(StepDurability.SYNC)
            .onExecuteFailureProceedTo(recoveryStep)
            .build();
}
  • Enum Constant Details

    • DEFAULT

      public static final StepDurability DEFAULT
      Uses the applicable Flow configuration or the synchronous server default.

      A method-level DEFAULT defers to FlowConfig. Without a Flow override, it resolves to SYNC. Failure policies do not change the result.

    • SYNC

      public static final StepDurability SYNC
      Persists the method result before Dex advances based on it.

      This adds persistence latency and reduces batching opportunities, but prevents a completed result from being lost solely because Dex advanced before recording it. Retries can still occur, so this mode does not remove the idempotency requirement.

    • ASYNC

      public static final StepDurability ASYNC
      Allows Dex to advance before the completed method result is durably recorded.

      This lowers latency and improves server throughput through batched persistence, while accepting that an extreme failure may lose an unpersisted result and cause the Step method to execute again. Dex first uses a local activity for at most seven seconds and three attempts, then falls back to a regular activity using the remaining retry budget.

  • Method Details

    • values

      public static StepDurability[] values()
      Returns an array containing the constants of this enum class, in the order they are declared.
      Returns:
      an array containing the constants of this enum class, in the order they are declared
    • valueOf

      public static StepDurability valueOf(String name)
      Returns the enum constant of this class with the specified name. The string must match exactly an identifier used to declare an enum constant in this class. (Extraneous whitespace characters are not permitted.)
      Parameters:
      name - the name of the enum constant to be returned.
      Returns:
      the enum constant with the specified name
      Throws:
      IllegalArgumentException - if this enum class has no constant with the specified name
      NullPointerException - if the argument is null