Interface TransactionalMap<K,V>

Type Parameters:
K - type of the map key
V - type of the map value
All Superinterfaces:
BaseMap<K,V>, DistributedObject, TransactionalObject

public interface TransactionalMap<K,V> extends TransactionalObject, BaseMap<K,V>
Transactional implementation of BaseMap.

MapStore Interaction

When using MapStore, the call to any MapStore method is outside the transactional boundary. If you need to have an XATransaction spanning Hazelcast operations and one more other XAResources (such as a database), you should not use MapStore. Instead, enlist both resources in a transaction as shown below:

 HazelcastInstance client = HazelcastClient.newHazelcastClient();

 UserTransactionManager tm = new UserTransactionManager();

 HazelcastXAResource xaResource = client.getXAResource();
 Transaction transaction = tm.getTransaction();

 // you can enlist more resources here like a database XAResource
 try {
      TransactionContext context = xaResource.getTransactionContext()
      TransactionalMap map = context.getMap("map");
      map.put("key", "value");
      final TransactionalQueue queue = context.getQueue("queue");

      // you can do other resource operations like store/delete to a database

      transaction.delistResource(xaResource, XAResource.TMSUCCESS);
 } catch (TransactionException t) {
      transaction.delistResource(xaResource, XAResource.TMFAIL);
See Also: