Package org.springframework.transaction

# Interface TransactionExecutionListener

public interface TransactionExecutionListener
Callback interface for stateless listening to transaction creation/completion steps in a transaction manager. This is primarily meant for observation and statistics; consider stateful transaction synchronizations for resource management purposes.

In contrast to synchronizations, the transaction execution listener contract is commonly supported for thread-bound transactions as well as reactive transactions. The callback-provided `TransactionExecution` object will be either a `TransactionStatus` (for a `PlatformTransactionManager` transaction) or a `ReactiveTransaction` (for a `ReactiveTransactionManager` transaction).

Since:
  6.1
Author:
  Juergen Hoeller
See Also:
  - `ConfigurableTransactionManager.addListener(org.springframework.transaction.TransactionExecutionListener)`
  - `TransactionSynchronizationManager.registerSynchronization(org.springframework.transaction.support.TransactionSynchronization)`
  - `TransactionSynchronizationManager.registerSynchronization(org.springframework.transaction.reactive.TransactionSynchronization)`

## Method Summary

Modifier and Type
Method
Description
`default void`
`afterBegin(TransactionExecution transaction, Throwable beginFailure)`
Callback after the transaction begin step.
`default void`
`afterCommit(TransactionExecution transaction, Throwable commitFailure)`
Callback after the transaction commit step.
`default void`
`afterRollback(TransactionExecution transaction, Throwable rollbackFailure)`
Callback after the transaction rollback step.
`default void`
`beforeBegin(TransactionExecution transaction)`
Callback before the transaction begin step.
`default void`
`beforeCommit(TransactionExecution transaction)`
Callback before the transaction commit step.
`default void`
`beforeRollback(TransactionExecution transaction)`
Callback before the transaction rollback step.

## Method Details

### beforeBegin

default void beforeBegin(TransactionExecution transaction)
Callback before the transaction begin step.

Parameters:
  `transaction` - the current transaction

### afterBegin

default void afterBegin(TransactionExecution transaction, @Nullable Throwable beginFailure)
Callback after the transaction begin step.

Parameters:
  `transaction` - the current transaction
  `beginFailure` - an exception occurring during begin (or `null` after a successful begin step)

### beforeCommit

default void beforeCommit(TransactionExecution transaction)
Callback before the transaction commit step.

Parameters:
  `transaction` - the current transaction

### afterCommit

default void afterCommit(TransactionExecution transaction, @Nullable Throwable commitFailure)
Callback after the transaction commit step.

Parameters:
  `transaction` - the current transaction
  `commitFailure` - an exception occurring during commit (or `null` after a successful commit step)

### beforeRollback

default void beforeRollback(TransactionExecution transaction)
Callback before the transaction rollback step.

Parameters:
  `transaction` - the current transaction

### afterRollback

default void afterRollback(TransactionExecution transaction, @Nullable Throwable rollbackFailure)
Callback after the transaction rollback step.

Parameters:
  `transaction` - the current transaction
  `rollbackFailure` - an exception occurring during rollback (or `null` after a successful rollback step)