Record Class TransactionContext
- Record Components:
contextId- stable non-ACID context identifierscope- logical scope represented by this contextcorrelation- correlation and causal metadataidempotencyKey- optional idempotency key for duplicate start or command handlingdedupeKey- optional dedupe key for application-level duplicate detectiondeliverySemantics- delivery semantics expected by the application actiondeadline- effective deadline, orInstant.MAXwhen absentcancellationRequested- whether cancellation has been requested for this contextparticipant- safe participant identitymetadata- redacted user metadata
- All Implemented Interfaces:
Serializable
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 Summary
ConstructorsConstructorDescriptionTransactionContext(TransactionContextId contextId, TransactionScope scope, TransactionCorrelation correlation, IdempotencyKey idempotencyKey, DedupeKey dedupeKey, DeliverySemantics deliverySemantics, Instant deadline, boolean cancellationRequested, TransactionParticipant participant, Map<String, String> metadata) Creates a validated immutable context. -
Method Summary
Modifier and TypeMethodDescriptionbooleanReturns the value of thecancellationRequestedrecord component.child(TransactionScope childScope) Returns a child context for a step.Returns the value of thecontextIdrecord component.Returns the value of thecorrelationrecord component.deadline()Returns the value of thedeadlinerecord component.Returns the value of thededupeKeyrecord component.Returns the value of thedeliverySemanticsrecord component.final booleanIndicates whether some other object is "equal to" this one.final inthashCode()Returns a hash code value for this object.Returns the value of theidempotencyKeyrecord component.metadata()Returns the value of themetadatarecord component.Returns the value of theparticipantrecord component.scope()Returns the value of thescoperecord component.final StringtoString()Returns a string representation of this record class.
-
Constructor Details
-
TransactionContext
public TransactionContext(TransactionContextId contextId, TransactionScope scope, TransactionCorrelation correlation, IdempotencyKey idempotencyKey, DedupeKey dedupeKey, DeliverySemantics deliverySemantics, Instant deadline, boolean cancellationRequested, TransactionParticipant participant, Map<String, String> metadata) Creates a validated immutable context.Missing identifiers, scope, correlation, delivery semantics, deadline, and participant values are replaced with safe defaults. Metadata is defensively copied and redacted. Equality is value based and suitable for deterministic context propagation tests.
-
-
Method Details
-
child
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
-
hashCode
-
equals
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 withObjects::equals(Object,Object); primitive components are compared with thecomparemethod from their corresponding wrapper classes. -
contextId
-
scope
-
correlation
Returns the value of thecorrelationrecord component.- Returns:
- the value of the
correlationrecord component
-
idempotencyKey
Returns the value of theidempotencyKeyrecord component.- Returns:
- the value of the
idempotencyKeyrecord component
-
dedupeKey
-
deliverySemantics
Returns the value of thedeliverySemanticsrecord component.- Returns:
- the value of the
deliverySemanticsrecord component
-
deadline
-
cancellationRequested
public boolean cancellationRequested()Returns the value of thecancellationRequestedrecord component.- Returns:
- the value of the
cancellationRequestedrecord component
-
participant
Returns the value of theparticipantrecord component.- Returns:
- the value of the
participantrecord component
-
metadata
-