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

@Internal public interface InternalTransaction<T> extends TransactionStatus<T>
The internal transaction representation.
Since:
4.0.0
Author:
Denis Stepanov
  • 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 setRollbackOnly on 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

      void registerResourceCommit(TransactionResourceCommit resourceCommit)
      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:
      true when a resource commit action was registered and executed
    • triggerAfterCompletion

      void triggerAfterCompletion(TransactionSynchronization.Status status)
    • 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, see bindConnectionSynchronizationsToTransaction().
    • registerConnectionSynchronization

      default void registerConnectionSynchronization(@NonNull ConnectionSynchronization synchronization)
      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 at cleanupAfterCompletion().
      Parameters:
      synchronization - The synchronization
      Since:
      5.3.0
    • bindConnectionSynchronizationsToTransaction

      default void bindConnectionSynchronizationsToTransaction()
      Binds the synchronizations registered by registerConnectionSynchronization(ConnectionSynchronization) to this transaction. Used when the transaction is started on a connection owned by an outer scope.
      Since:
      5.3.0
    • bindConnectionSynchronizationsToTransaction

      default void bindConnectionSynchronizationsToTransaction(@NonNull Runnable release)
      Binds the synchronizations registered by registerConnectionSynchronization(ConnectionSynchronization) and the release of the connection to this transaction. Used when the transaction owns the connection. The connection is released at cleanupAfterCompletion(), 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

      void registerInvocationSynchronization(@NonNull TransactionSynchronization synchronization)
      The variation of TransactionStatus.registerSynchronization(TransactionSynchronization) that is always executed on the current TX invocation. The ordinary TransactionStatus.registerSynchronization(TransactionSynchronization) will always bound the synchronization to the TX in progress.
      Parameters:
      synchronization - The synchronization