LATEST VERSION: 8.2.5 - CHANGELOG
Pivotal GemFire® v8.2

Transactions Example

Transactions Example

You can group cache updates with Pivotal GemFire transactions and create dependencies between cache modifications so that they all complete together or fail together.

You can execute transactions against the data in the distributed cache similar to the way you execute transactions in a database, with the standard begin, commit, and rollback operations. GemFire transactions are compatible with Java Transaction API (JTA) transactions and, when run inside a J2EE container, are also compatible with the container's JNDI and JTA transaction manager.

Running the Example

This example runs and commits one transaction and then runs and rolls back another.

Note: To run this example, you must have terminal sessions configured for the QuickStart examples, as described in Setting Up Your Environment for Running the Examples.

In a single session, run the example:

$ java -cp "$GEMFIRE/SampleCode/quickstart/classes:$GEMFIRE/lib/server-dependencies.jar" quickstart.Transactions

Example Source Files

Program and cache configuration files:

Table 1. Cache configuration files, located in SampleCode//quickstart/xml
Transactions.xml Configures a simple distributed region.
Table 2. Java program files, located in SampleCode//quickstart/quickstart
Transactions.java Demonstrates executing transactions against a distributed cache.
Related Topics
Transactions

Related Javadocs

  • com.gemstone.gemfire.cache.CacheTransactionManager
  • com.gemstone.gemfire.cache.TransactionEvent
  • com.gemstone.gemfire.cache.TransactionListener