Really easy integration of Hazelcast with Atomikos JTA/XA functionality…

The Problem

You want to update your distributed cache, but only if you succeed in other operations like updating a DBMS or sending a message to a queue.

The Solution

Use our Hazelcast integration to update the cache, and the outcome will be automatically subject to commit / rollback of any JTA transactions in your application.

Code sample

import com.hazelcast.core.HazelcastInstance;
import com.hazelcast.core.TransactionalMap;
import com.hazelcast.instance.HazelcastInstanceFactory;
import com.hazelcast.transaction.TransactionContext;
import org.springframework.transaction.annotation.Transactional;
import javax.annotation.PostContruct;
import com.atomikos.hazelcast.AtomikosHazelcastInstanceFactory;

@Transactional
public class BlogPostDemoTest {

   private HazelcastInstance jtaAwareInstance; // this instance will make Hazelcast transactional operations part of JTA

   @PostConstruct public void init() {
      HazelcastInstance nativeInstance = HazelcastInstanceFactory.newHazelcastInstance(...); // create native instance
      jtaAwareInstance = AtomikosHazelcastInstanceFactory.createJtaAwareHazelcastInstance("hazelcast", nativeInstance);
   }

   public void updateCacheInJta() {
      TransactionContext ctx = jtaAwareInstance.newTransactionContext(); // can be called multiple times inside the same JTA transaction
      final TransactionalMap<Object, Object> map = ctx.getMap("map");
      map.put("key", "value");
   }
}

Availability

This will be part of our 5.0 release of ExtremeTransactions. Subscribe to our mailing list to get notified when it is available:

Contact Us

Atomikos Corporate Headquarters
Hoveniersstraat, 39/1, 2800
Mechelen, Belgium

E info@atomikos.com
E sales@atomikos.com
T +3215613055

Subscribe to our newsletter

Never miss an update

Copyright 2019 Atomikos BVBA
This website is using cookies. More info. That's Fine