Interface InternalTransaction<T>
- Type Parameters:
T- The transaction type
- All Superinterfaces:
io.micronaut.core.propagation.PropagatedContextElement, TransactionExecution, TransactionStatus<T>
- All Known Implementing Classes:
AbstractInternalTransaction, DefaultTransactionStatus
The internal transaction representation.
- Since:
- 4.0.0
- Author:
- Denis Stepanov
-
Method Summary
Modifier and TypeMethodDescriptiondefault voidBinds the synchronizations registered byregisterConnectionSynchronization(ConnectionSynchronization)to this transaction.default voidbindConnectionSynchronizationsToTransaction(@NonNull Runnable release) Binds the synchronizations registered byregisterConnectionSynchronization(ConnectionSynchronization)and the release of the connection to this transaction.voidFinal cleanup after the transaction completed, always invoked even if an earlier completion step failed.default voidDiscards the connection synchronizations bound to this transaction without executing them.booleanTemplate method for determining the global rollback-only flag of the underlying transaction, if any.booleanDetermine the rollback-only flag via checking this TransactionStatus.booleanCheck if the current TX is nested.default voidregisterConnectionSynchronization(@NonNull ConnectionSynchronization synchronization) Registers a synchronization restoring the connection state changed by this transaction.voidregisterInvocationSynchronization(@NonNull TransactionSynchronization synchronization) The variation ofTransactionStatus.registerSynchronization(TransactionSynchronization)that is always executed on the current TX invocation.voidregisterResourceCommit(TransactionResourceCommit resourceCommit) Registers vendor-specific work for the resource commit boundary.default voidresume()default voidsuspend()voidvoidvoidvoidbooleanRuns a registered resource commit action.Methods inherited from interface TransactionExecution
getTransactionDefinition, isCompleted, isNewTransaction, isRollbackOnly, setRollbackOnlyMethods inherited from interface TransactionStatus
getConnection, getConnectionStatus, getTransaction, propagate, propagate, propagate, registerSynchronization
-
Method Details
-
isNestedTransaction
boolean isNestedTransaction()Check if the current TX is nested.- Returns:
- true if is nested transaction
- Since:
- 4.1.0
-
isLocalRollbackOnly
boolean isLocalRollbackOnly()Determine the rollback-only flag via checking this TransactionStatus.Will only return "true" if the application called
setRollbackOnlyon this TransactionStatus object.- Returns:
- Whether is local rollback
-
isGlobalRollbackOnly
boolean isGlobalRollbackOnly()Template method for determining the global rollback-only flag of the underlying transaction, if any.This implementation always returns
false.- Returns:
- Whether is global rollback
-
suspend
default void suspend() -
resume
default void resume() -
triggerBeforeCommit
void triggerBeforeCommit() -
triggerAfterCommit
void triggerAfterCommit() -
triggerBeforeCompletion
void triggerBeforeCompletion() -
registerResourceCommit
Registers vendor-specific work for the resource commit boundary.- Parameters:
resourceCommit- The resource commit callback
-
triggerResourceCommit
boolean triggerResourceCommit()Runs a registered resource commit action.- Returns:
truewhen a resource commit action was registered and executed
-
triggerAfterCompletion
-
cleanupAfterCompletion
void cleanupAfterCompletion()Final cleanup after the transaction completed, always invoked even if an earlier completion step failed. Runs the connection synchronizations bound to this transaction, seebindConnectionSynchronizationsToTransaction(). -
registerConnectionSynchronization
Registers a synchronization restoring the connection state changed by this transaction. By default, the synchronization is registered on the connection status; if the transaction reuses a connection owned by an outer scope, it is executed atcleanupAfterCompletion().- Parameters:
synchronization- The synchronization- Since:
- 5.3.0
-
bindConnectionSynchronizationsToTransaction
default void bindConnectionSynchronizationsToTransaction()Binds the synchronizations registered byregisterConnectionSynchronization(ConnectionSynchronization)to this transaction. Used when the transaction is started on a connection owned by an outer scope.- Since:
- 5.3.0
-
bindConnectionSynchronizationsToTransaction
Binds the synchronizations registered byregisterConnectionSynchronization(ConnectionSynchronization)and the release of the connection to this transaction. Used when the transaction owns the connection. The connection is released atcleanupAfterCompletion(), after the connection state is restored.- Parameters:
release- The release of the connection- Since:
- 5.3.0
-
discardConnectionSynchronizations
default void discardConnectionSynchronizations()Discards the connection synchronizations bound to this transaction without executing them. Used when restoring the connection state is unsafe, for example, restoring the auto-commit of a partially started transaction that couldn't be rolled back would commit it.- Since:
- 5.3.0
-
registerInvocationSynchronization
The variation ofTransactionStatus.registerSynchronization(TransactionSynchronization)that is always executed on the current TX invocation. The ordinaryTransactionStatus.registerSynchronization(TransactionSynchronization)will always bound the synchronization to the TX in progress.- Parameters:
synchronization- The synchronization
-