Record Class TransactionContext

java.lang.Object
java.lang.Record
org.j7m.middleware.api.saga.TransactionContext
Record Components:
contextId - stable non-ACID context identifier
scope - logical scope represented by this context
correlation - correlation and causal metadata
idempotencyKey - optional idempotency key for duplicate start or command handling
dedupeKey - optional dedupe key for application-level duplicate detection
deliverySemantics - delivery semantics expected by the application action
deadline - effective deadline, or Instant.MAX when absent
cancellationRequested - whether cancellation has been requested for this context
participant - safe participant identity
metadata - redacted user metadata
All Implemented Interfaces:
Serializable

public record TransactionContext(TransactionContextId contextId, TransactionScope scope, TransactionCorrelation correlation, IdempotencyKey idempotencyKey, DedupeKey dedupeKey, DeliverySemantics deliverySemantics, Instant deadline, boolean cancellationRequested, TransactionParticipant participant, Map<String,String> metadata) extends Record implements Serializable
Propagated saga transaction context; this is not an ACID transaction.

The context is immutable and thread-safe. It carries correlation, idempotency, dedupe, delivery, deadline, cancellation, participant, and redacted metadata across saga steps. It is local propagation metadata, not a lock, XA resource, or two-phase-commit participant. Implementations must clear any thread-local or execution-local view after a step completes so context does not leak between executions.

Public status should normally expose TransactionContextSummary rather than this full context. Metadata is redacted on construction using the saga redaction policy; callers must not place command payload bytes or credential material in keys that need to remain visible.

See Also:
  • Constructor Details

  • Method Details

    • child

      public TransactionContext child(TransactionScope childScope)
      Returns a child context for a step.

      The child receives a new context id and child causal operation while preserving correlation, idempotency, dedupe, deadline, cancellation, participant, and redacted metadata. The method does not mutate this context and does not install thread-local state.

      Parameters:
      childScope - child scope to assign
      Returns:
      immutable child context preserving parent correlation and deadline data
    • toString

      public final String toString()
      Returns a string representation of this record class. The representation contains the name of the class, followed by the name and value of each of the record components.
      Specified by:
      toString in class Record
      Returns:
      a string representation of this object
    • hashCode

      public final int hashCode()
      Returns a hash code value for this object. The value is derived from the hash code of each of the record components.
      Specified by:
      hashCode in class Record
      Returns:
      a hash code value for this object
    • equals

      public final boolean equals(Object o)
      Indicates whether some other object is "equal to" this one. The objects are equal if the other object is of the same class and if all the record components are equal. Reference components are compared with Objects::equals(Object,Object); primitive components are compared with the compare method from their corresponding wrapper classes.
      Specified by:
      equals in class Record
      Parameters:
      o - the object with which to compare
      Returns:
      true if this object is the same as the o argument; false otherwise.
    • contextId

      public TransactionContextId contextId()
      Returns the value of the contextId record component.
      Returns:
      the value of the contextId record component
    • scope

      public TransactionScope scope()
      Returns the value of the scope record component.
      Returns:
      the value of the scope record component
    • correlation

      public TransactionCorrelation correlation()
      Returns the value of the correlation record component.
      Returns:
      the value of the correlation record component
    • idempotencyKey

      public IdempotencyKey idempotencyKey()
      Returns the value of the idempotencyKey record component.
      Returns:
      the value of the idempotencyKey record component
    • dedupeKey

      public DedupeKey dedupeKey()
      Returns the value of the dedupeKey record component.
      Returns:
      the value of the dedupeKey record component
    • deliverySemantics

      public DeliverySemantics deliverySemantics()
      Returns the value of the deliverySemantics record component.
      Returns:
      the value of the deliverySemantics record component
    • deadline

      public Instant deadline()
      Returns the value of the deadline record component.
      Returns:
      the value of the deadline record component
    • cancellationRequested

      public boolean cancellationRequested()
      Returns the value of the cancellationRequested record component.
      Returns:
      the value of the cancellationRequested record component
    • participant

      public TransactionParticipant participant()
      Returns the value of the participant record component.
      Returns:
      the value of the participant record component
    • metadata

      public Map<String,String> metadata()
      Returns the value of the metadata record component.
      Returns:
      the value of the metadata record component