Class Timer

java.lang.Object
io.superdurable.dex.Timer

public final class Timer extends Object
Creates server-side durable timer conditions for Step waits.

This is not a JVM timer and does not require the Worker process to remain running. Dex stores the timer as part of the durable Flow execution on the server, so the deadline remains scheduled across Worker disconnections, process restarts, and machine failures. No Java thread is blocked while the timer is pending. When the server-side timer fires and the surrounding Wait is satisfied, Dex invokes the Step through an available Worker. Add a stable condition ID when application code needs to inspect or skip a specific timer later.

public Wait waitFor(Context context, Order input) {
    return Wait.until(Timer.byDuration(Duration.ofMinutes(10), "payment-timeout"));
}
  • Method Details

    • byDuration

      public static Condition byDuration(Duration duration)
      Creates a server-side durable timer condition without a condition ID.
      Parameters:
      duration - the nonnegative delay before the timer fires
      Returns:
      the timer condition
      Throws:
      IllegalArgumentException - if duration is null or negative
    • byDuration

      public static Condition byDuration(Duration duration, String conditionId)
      Creates a server-side durable timer condition with a stable condition ID.
      Parameters:
      duration - the nonnegative delay before the timer fires
      conditionId - the ID used to inspect or skip this timer
      Returns:
      the timer condition
      Throws:
      IllegalArgumentException - if duration is null or negative