Interface TransactionEventListener<T>

Type Parameters:
T - The type of a state object that the transaction handler can use to pass information from the beforeCommit(TransactionData, Transaction, GraphDatabaseService) event dispatch method to the afterCommit(TransactionData, Object, GraphDatabaseService) or afterRollback(TransactionData, Object, GraphDatabaseService) method, depending on whether the transaction succeeded or failed.

public interface TransactionEventListener<T>
An event handler interface for transaction events. Once it has been registered at a DatabaseManagementService instance it will receive events about what has happened in each transaction which is about to be committed and has any data that is accessible via TransactionData. Handlers won't get notified about transactions which haven't performed any write operation or won't be committed (either if Transaction.commit() hasn't been called or the transaction has been rolled back, Transaction.rollback()).

Right before a transaction is about to be committed the beforeCommit(TransactionData, Transaction, GraphDatabaseService) method is called with the entire diff of modifications made in the transaction. At this point the transaction is still running so changes can still be made. However, there's no guarantee that other handlers will see such changes since the order in which handlers are executed is undefined. This method can also throw an exception and will, in such a case, prevent the transaction from being committed.

If beforeCommit(TransactionData, Transaction, GraphDatabaseService) is successfully executed the transaction will be committed and the afterCommit(TransactionData, Object, GraphDatabaseService) method will be called with the same transaction data as well as the object returned from beforeCommit(TransactionData, Transaction, GraphDatabaseService). This assumes that all other handlers (if more were registered) also executed beforeCommit(TransactionData, Transaction, GraphDatabaseService) successfully.

If beforeCommit(TransactionData, Transaction, GraphDatabaseService) isn't executed successfully, but instead throws an exception the transaction won't be committed. Transient errors of type TransientFailureException will (eventually) be rethrown. For all other errors a TransactionFailureException will (eventually) be thrown from Transaction.close(). All handlers which at this point have had its beforeCommit(TransactionData, Transaction, GraphDatabaseService) method executed successfully will receive a call to afterRollback(TransactionData, Object, GraphDatabaseService).