Class ManagedSagaContext

java.lang.Object
org.j7m.middleware.application.distributed.ManagedSagaContext

public final class ManagedSagaContext extends Object
Revocable current saga callback capability, installed only by its actual trusted host policy. Staged protected CAS effects commit atomically with a forward step's durable successful result; they are not immediate writes and cannot protect arbitrary external effects. A captured context never authorizes a different callback or work after the original USER scope has sealed.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    Returns the native run ownership fence.
    Returns the exact external protocol key retained across safe replay and takeover.
    long
    Returns the immutable source ownership epoch pinned when this callback was admitted.
    boolean
    Observes local revocation without acquiring or renewing any authority.
    Returns the stable logical saga identity for this callback.
    void
    stageEffect(String key, long expectedVersion, String value)
    Stages a bounded native execution-map compare-and-set for successful forward completion.
    Returns the persisted step identity.
    Omits business identities and staged values from diagnostics.

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Method Details

    • sagaId

      public String sagaId()
      Returns the stable logical saga identity for this callback.
      Returns:
      original run identity
      Throws:
      org.j7m.middleware.api.MiddlewareException - outside this live callback
    • step

      public String step()
      Returns the persisted step identity.
      Returns:
      stable step name
      Throws:
      org.j7m.middleware.api.MiddlewareException - outside this live callback
    • idempotencyKey

      public String idempotencyKey()
      Returns the exact external protocol key retained across safe replay and takeover. The application must actually send this key to an external service that honors idempotency.
      Returns:
      persisted key; compensation uses its original step key with a fixed compensation suffix
      Throws:
      org.j7m.middleware.api.MiddlewareException - outside this live callback
    • fence

      public long fence()
      Returns the native run ownership fence. It is not an arbitrary database lock token.
      Returns:
      current native fence
      Throws:
      org.j7m.middleware.api.MiddlewareException - outside this live callback
    • partitionEpoch

      public long partitionEpoch()
      Returns the immutable source ownership epoch pinned when this callback was admitted. It never follows a migrated partition; the final native mutation verifies the same epoch.
      Returns:
      captured positive partition epoch
      Throws:
      org.j7m.middleware.api.MiddlewareException - outside this live callback
    • revoked

      public boolean revoked()
      Observes local revocation without acquiring or renewing any authority.
      Returns:
      whether this context has been revoked or its conservative local lease has expired
    • stageEffect

      public void stageEffect(String key, long expectedVersion, String value)
      Stages a bounded native execution-map compare-and-set for successful forward completion. The host namespaces the key. At most16 distinct keys fit one callback; duplicate keys fail before a native mutation. Compensation cannot stage these effects because its native result protocol has no atomic protected-map effect boundary.
      Parameters:
      key - application key, 1..128 identifier characters
      expectedVersion - exact current native value version, zero for absence
      value - string value, at most4096 UTF16 code units and no NUL
      Throws:
      org.j7m.middleware.api.MiddlewareException - after revocation, cancellation or the original deadline
      IllegalArgumentException - for compensation, duplicate key or invalid/bounded input
    • toString

      public String toString()
      Omits business identities and staged values from diagnostics.
      Overrides:
      toString in class Object
      Returns:
      fixed safe label