[Version 8.6 and later][Java programming language only]

Developing applications to write to multi-partition transactions for WebSphere eXtreme Scale in a stand-alone environment

[Version 8.6 and later] You can write an application for a distributed data grid with multiple partitions in your stand-alone WebSphere® eXtreme Scale environment.

Before you begin

Enable the eXtremeIO protocol. For more information, see Configuring IBM eXtremeIO (XIO).
Restriction: You should note the following restrictions before developing applications to write to multi-partition transactions.
  • You cannot use multi-partitions in a WebSphere eXtreme Scale Client in a .NET environment.
  • BackingMaps that are configured with a Loader plug-in can read but cannot write to the map in a multi-partition transaction.
  • BackingMaps that are using locking strategy as NONE cannot participate in multi-partition transactions.

About this task

Use the set TxCommitProtocol Session API to enable multi-partition transaction support for WebSphere eXtreme Scale in a stand-alone environment. The new API provides the following two options:
  • TxCommitProtocol.ONEPHASE: A transaction commit protocol constant that indicates that the transaction must be committed with the default one-phase commit. With this option, a transaction can read from multiple partitions but can write to a single partition only. A TransactionException exception occurs if the transaction writes to multiple partitions.
  • TxCommitProtocol.TWOPHASE: A transaction commit protocol constant that indicates that the transaction must be committed either with the one-phase commit or two-phase commit. If the transaction writes to a single partition then the one-phase commit protocol is used. Otherwise, the two-phase protocol is used to commit the transaction, involving write operations to multiple partitions.
You can also configure multi-transaction support for WebSphere eXtreme Scale within WebSphere Application Server. For more information, see Developing eXtreme Scale client components to use transactions.

Procedure

  1. Connect to the data grid.
  2. Obtain an data grid session instance with the ObjectGrid.getSession method.
  3. Enable a two-phase commit protocol by setting the following code snippet:
    session.setTxCommitProtocol(Session.TxCommitProtocol.TWOPHASE); session.begin(); The following code snippet illustrates how to create, retrieve, update, and delete operations in a grid with a two-phase commit protocol:
    Session session = og.getSession();
    Objectmap map1 = session.getMap("Map1");
    Objectmap map2 = session.getMap("Map2");
    Objectmap map3 = session.getMap("Map3");
    session.setTxCommitProtocol(Session.TxCommitProtocol.TWOPHASE);
    session.begin();
    map1.insert("randKey345", "HelloMap1");
    map2.insert("randKey58901", "HelloMap2");
    map3.insert("randKey58", "HelloMap3");
    session.commit();

What to do next

You can enable tracing on multi-partition transactions. For more information, see Server trace options.