Real­ly easy in­te­gra­tion of Hazel­cast with Atomikos JTA/XA func­tion­al­i­ty...

The Prob­lem

You want to up­date your dis­trib­uted cache, but only if you suc­ceed in oth­er op­er­a­tions like up­dat­ing a DBMS or send­ing a mes­sage to a queue.

The So­lu­tion

Use our Hazel­cast in­te­gra­tion to up­date the cache, and the out­come will be au­to­mat­i­cal­ly sub­ject to com­mit / roll­back of any JTA trans­ac­tions in your ap­pli­ca­tion.

Code sam­ple

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");
   }
}

Avail­abil­i­ty

This will be part of our 5.0 re­lease of Ex­tremeTrans­ac­tions. Sub­scribe to our mail­ing list to get no­ti­fied when it is avail­able:

No­ti­fy me!

RSS

Com­ments

Add a com­ment

Cor­po­rate In­for­ma­tion

Atomikos Cor­po­rate Head­quar­ters
Hove­niersstraat, 39/1, 2800
Meche­len, Bel­gium

Con­tact Us

Copy­right 2026 Atomikos BVBA | Our Pri­va­cy Pol­i­cy
By us­ing this site you agree to our cook­ies. More info. That's Fine