Transactions Example

You can group cache updates with GemFire transactions. Transactions allow you to create dependencies between cache modifications so they all either 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.

In a single session, run the example:

$ java quickstart.Transactions

Example Source Files

Program and cache configuration files:

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

Related Javadocs