com.gemstone.gemfire.cache
Interface CacheTransactionManager

public interface CacheTransactionManager

The CacheTransactionManager interface allows applications to manage
transactions on a per Cache basis.

The life cycle of a GemFire transaction starts with a begin
operation. The life cycle ends with either a commit or rollback
operation. Between the begin and the commit/rollback are typically
Region operations. In general, those that either create,
destroy, invalidate or update Region.Entry are considered
transactional, that is they modify transactional state.

A GemFire transaction may involve operations on multiple regions,
each of which may have different attributes.

While a GemFire transaction and its operations are invoked in
the local VM, the resulting transaction state is distributed to
other VM's at commit time as per the attributes of each
participant Region.

A transaction can have no more than one thread associated with
it and conversely a thread can only operate on one transaction at
any given time. Child threads will not inherit the existing
transaction.

Each of the following methods operate on the current thread. All
methods throw CacheClosedException if the Cache is closed.

GemFire Transactions currently only support Read Committed
isolation. In addition, they are optimistic transactions in that
write locking and conflict checks are performed as part of the
commit operation.

For guaranteed Read Committed isolation, avoid making "in place"
changes, because such changes will be "seen" by other transactions
and break the Read Committed isolation guarantee. e.g.

When PartitionedRegions are involved in a transaction, all data in the
transaction must be colocated together on one data node. See the GemFire
Developer Guide for details on using transactions with Partitioned Regions.

tryResume(TransactionId transactionId,
long time,
TimeUnit unit)
On the current thread, resumes a transaction that was previously suspended
using suspend(), or waits for the specified timeout interval if
the transaction has not been suspended.

commit

Commit the transaction associated with the current thread. If
the commit operation fails due to a conflict it will destroy
the transaction state and throw a CommitConflictException. If the commit operation succeeds,
it returns after the transaction state has been merged with
committed state. When this method completes, the thread is no
longer associated with a transaction.

TransactionDataNotColocatedException - if at commit time, the data
involved in the transaction has moved away from the transaction hosting
node. This can only happen if rebalancing/recovery happens during a
transaction that involves a PartitionedRegion.

TransactionInDoubtException - when GemFire cannot tell which nodes
have applied the transaction and which have not. This only occurs if nodes
fail mid-commit, and only then in very rare circumstances.

rollback

void rollback()

Roll back the transaction associated with the current thread. When
this method completes, the thread is no longer associated with a
transaction and the transaction context is destroyed.

tryResume

On the current thread, resumes a transaction that was previously suspended
using suspend(), or waits for the specified timeout interval if
the transaction has not been suspended. This method will return if:

removeListener

Removes a transaction listener from the list of transaction listeners on this cache.
Does nothing if the specified listener has not been added.
If the specified listener has been added then CacheCallback.close() will
be called on it; otherwise does nothing.