Interface Step<I>

Type Parameters:
I - the concrete Java input type accepted by this Step

public interface Step<I>
Implements one durable unit of Flow logic.

waitFor(Context, I) is optional. When a Step does not override it, Dex skips the waiting phase and invokes execute(Context, I) immediately. When a Step implements waitFor, Dex invokes execute after the declared durable conditions are satisfied. Both methods are synchronous Java calls executed by the worker's bounded executor. A Step instance is shared across invocations, so keep per-execution state in Context, Attributes, or method-local variables rather than mutable instance fields.

final class ChargeOrder implements Step<OrderInput> {
    @Override
    public Class<OrderInput> getInputType() {
        return OrderInput.class;
    }

    @Override
    public Wait waitFor(Context context, OrderInput input) {
        return Wait.until(payment.forOne());
    }

    @Override
    public StepDecision execute(Context context, OrderInput input) {
        return StepDecision.gracefulComplete(input.orderId);
    }
}
  • Method Summary

    Modifier and Type
    Method
    Description
    execute(Context context, I input)
    Executes the Step's application logic and returns its durable decision.
    Returns the concrete class used to decode this Step's input.
    default StepOptions
    Returns retry, timeout, durability, locking, and failure behavior for this Step.
    default String
    Returns the Step type used to register this Step.
    default Wait
    waitFor(Context context, I input)
    Declares the conditions that must be satisfied before execution.
  • Method Details

    • getInputType

      Class<I> getInputType()
      Returns the concrete class used to decode this Step's input.

      The class must agree with I. A parameterized input such as List<Order> cannot be returned because List.class does not retain its element type. Wrap the list in a concrete input class and return that wrapper's class, or use Order[].class when an array fits the input model.

      Returns:
      the concrete, nonnull Step input class
    • execute

      StepDecision execute(Context context, I input)
      Executes the Step's application logic and returns its durable decision.
      Parameters:
      context - the invocation-scoped Flow context
      input - the decoded Step input, which may be null for Void Steps
      Returns:
      the nonnull decision describing the next durable action
    • waitFor

      default Wait waitFor(Context context, I input)
      Declares the conditions that must be satisfied before execution.

      When this method is not overridden, the registry marks the Step to skip wait-for invocation and execute immediately. An override may also return Wait.skipImmediately() explicitly.

      Parameters:
      context - the invocation-scoped Flow context
      input - the decoded Step input
      Returns:
      the nonnull durable wait definition
    • getStepType

      default String getStepType()
      Returns the Step type used to register this Step.

      The default is getClass().getSimpleName(). Use an explicit named class or override this method so refactoring does not accidentally change the Step type stored by Dex.

      Returns:
      the nonblank Step type
    • getStepOptions

      default StepOptions getStepOptions()
      Returns retry, timeout, durability, locking, and failure behavior for this Step.
      Returns:
      Step-specific options, or null to use all defaults