TransactionWriter (Apache Geode 1.15.4)

org.apache.geode.cache

## Interface TransactionWriter

- All Superinterfaces:
    CacheCallback, Declarable

      public interface TransactionWriter
      extends CacheCallback

  A callback that is allowed to veto a transaction. Only one TransactionWriter can exist per cache, and only one TransactionWriter will be fired in the entire distributed system for each transaction.

  This writer can be used to update a backend data source before the GemFire cache is updated during commit. If the backend update fails, the implementer can throw a `TransactionWriterException` to veto the transaction.

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

  Since:
    GemFire 6.5
  See Also:
    `CacheTransactionManager.setWriter(org.apache.geode.cache.TransactionWriter)`

- - ### Method Summary

    All Methods Instance Methods Abstract Methods
    Modifier and Type | Method and Description
    --- | ---
    `void` | `beforeCommit(TransactionEvent event)` Called before the transaction has finished committing, but after conflict checking.

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

      `close`

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

      `init, initialize`

- - ### Method Detail

    - #### beforeCommit

          void beforeCommit(TransactionEvent event)
                     throws TransactionWriterException

      Called before the transaction has finished committing, but after conflict checking. Provides an opportunity for implementors to cause transaction abort by throwing a TransactionWriterException
      Parameters:
        `event` - the TransactionEvent
      Throws:
        `TransactionWriterException` - in the event that the transaction should be rolled back
      See Also:
        `CacheTransactionManager.commit()`