Class Stream<T>

Type Parameters:
T - the message type

public final class Stream<T> extends PersistenceDefinition
Defines a typed best-effort resumable message Stream owned by one Flow type.

Register the exact definition in one PersistenceSchema. All instances of that Flow type share the approximate byte budget. Step writes are immediate and do not roll back when the handler later fails.

  • Method Details

    • define

      public static <T> Stream<T> define(String name, Class<T> valueType, long streamCapacityBytes)
      Creates a typed Stream definition.
      Type Parameters:
      T - the message type
      Parameters:
      name - the nonblank logical name unique within its Flow
      valueType - the concrete message class used for decoding
      streamCapacityBytes - the positive approximate shared byte budget
      Returns:
      an immutable Stream definition
    • write

      public void write(Context context, T value)
      Appends one message immediately from the current Step execution.

      This method sends a fire-and-forget frame to Dex. It may be called repeatedly for the same Stream. Each frame also acts as an implicit activity heartbeat. Storage failures do not fail the Step, but local validation, serialization, or transport failures may throw.

      Parameters:
      context - the current Step Context; RPC and Flow timeout Contexts are rejected
      value - the typed message to append
      Throws:
      IllegalStateException - if the Context belongs to an RPC or Flow timeout handler
      io.grpc.StatusRuntimeException - if the Step invocation is canceled or transport fails
      ValueMappingException - if the value cannot be encoded
    • getStreamName

      public String getStreamName()
      Returns the logical Stream name.
      Returns:
      the stable protocol name
    • getStreamCapacityBytes

      public long getStreamCapacityBytes()
      Returns the approximate shared byte budget.
      Returns:
      the positive budget in bytes