Class RecoverableTransactionContext
java.lang.Object
io.micronaut.transaction.recovery.RecoverableTransactionContext
- All Implemented Interfaces:
io.micronaut.core.propagation.PropagatedContextElement
@Internal
public final class RecoverableTransactionContext
extends Object
implements io.micronaut.core.propagation.PropagatedContextElement
Transaction-recovery state scoped to a single transactional invocation.
- Since:
- 5.2
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionvoidcaptureRecoveryToken(@NonNull TransactionStatus<?> status) Captures the vendor transaction token at the resource manager's commit boundary.voidconfigure(@NonNull TransactionStatus<?> transactionStatus, @NonNull CommitOutcomeResolver resolver) Enables recovery for the transaction started by the intercepted invocation.static @NonNull Optional<RecoverableTransactionContext> find()@Nullable CommitOutcomeResolver@Nullable Object@Nullable ObjectgetToken()booleanhasCapturedToken(@NonNull TransactionStatus<?> status) void
-
Constructor Details
-
RecoverableTransactionContext
public RecoverableTransactionContext()
-
-
Method Details
-
find
- Returns:
- The current recovery context, if recovery execution is active
-
configure
public void configure(@NonNull TransactionStatus<?> transactionStatus, @NonNull CommitOutcomeResolver resolver) Enables recovery for the transaction started by the intercepted invocation.- Parameters:
transactionStatus- The transaction that owns the commit boundaryresolver- The datasource-specific outcome resolver
-
captureRecoveryToken
Captures the vendor transaction token at the resource manager's commit boundary.- Parameters:
status- The transaction about to commit
-
getResolver
- Returns:
- The resolver selected for this transaction, if recovery was enabled
-
getToken
- Returns:
- The token captured immediately before the resource commit, if available
-
hasCapturedToken
- Parameters:
status- The transaction whose completion is restoring connection state- Returns:
- Whether this transaction has reached its commit boundary
-
setResult
- Parameters:
result- The intercepted method result
-
getResult
- Returns:
- The intercepted method result
-