Giriş
Şu satırı dahil ederiz
import com.hazelcast.transaction.TransactionalMap;
TransactionContext tarafından yaratılır
Örnek
Şöyle yaparız
TransactionalMap<String,Serializable> transactionalMap = transactionalContext.getMap("...");
Örnek
Şöyle yaparız
HazelcastInstance hazelcastInstance = Hazelcast.newHazelcastInstance(); TransactionOptions options = new TransactionOptions() .setTransactionType(TransactionOptions.TransactionType.ONE_PHASE ); TransactionContext context = hazelcastInstance.newTransactionContext(options); context.beginTransaction(); TransactionalQueue queue = context.getQueue("myqueue"); TransactionalMap map = context.getMap("mymap"); TransactionalSet set = context.getSet("myset"); try { Object obj = queue.poll(); //process obj map.put("1", "value1"); set.add("value"); //do other things context.commitTransaction(); } catch (Throwable t) { context.rollbackTransaction(); }
Hiç yorum yok:
Yorum Gönder