org.apache.geode.cache

## Interface TransactionListener<K,V>

- All Superinterfaces:
    CacheCallback, Declarable
  All Known Implementing Classes:
    TransactionListenerAdapter

      public interface TransactionListener<K,V>
      extends CacheCallback

  A listener that can be implemented to handle transaction related events. The methods on `TransactionListener` are invoked synchronously after the operation, commit or rollback, completes. The transaction that causes the listener to be called will no longer exist at the time the listener code executes. The thread that performed the transaction operation will not see that operation complete until the listener method completes its execution.

  Multiple transactions, on the same cache, can cause concurrent invocation of `TransactionListener` methods. Any exceptions thrown by the listener are caught and logged.

  Rollback and failed commit operations are local.

  WARNING: To avoid risk of deadlock, do not invoke CacheFactory.getAnyInstance() from within any callback methods. Instead use TransactionEvent.getCache().

  Since:
    GemFire 4.0
  See Also:
    `CacheTransactionManager.setListener(org.apache.geode.cache.TransactionListener)`, `CacheTransactionManager.getListener()`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `afterCommit(TransactionEvent<K,V> event)` Called after a successful commit of a transaction.
    `void` | `afterFailedCommit(TransactionEvent<K,V> event)` Called after an unsuccessful commit operation.
    `void` | `afterRollback(TransactionEvent<K,V> event)` Called after an explicit rollback of a transaction.

    - ### Methods inherited from interface org.apache.geode.cache.CacheCallback

      `close`

    - ### Methods inherited from interface org.apache.geode.cache.Declarable

      `init, initialize`

- - ### Method Detail

    - #### afterCommit

          void afterCommit(TransactionEvent<K,V> event)

      Called after a successful commit of a transaction.
      Parameters:
        `event` - the TransactionEvent
      See Also:
        `CacheTransactionManager.commit()`

    - #### afterFailedCommit

          void afterFailedCommit(TransactionEvent<K,V> event)

      Called after an unsuccessful commit operation.
      Parameters:
        `event` - the TransactionEvent
      See Also:
        `CacheTransactionManager.commit()`

    - #### afterRollback

          void afterRollback(TransactionEvent<K,V> event)

      Called after an explicit rollback of a transaction.
      Parameters:
        `event` - the TransactionEvent
      See Also:
        `CacheTransactionManager.rollback()`, `CacheTransactionManager.commit()`