The Artima Developer Community
Sponsored Link

Java Buzz Forum
Transactional Distributed Queue, Map, Set and List

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
Talip Ozturk

Posts: 103
Nickname: talip
Registered: May, 2003

Talip Ozturk is founder of Hazelcast, distributed queue, set, map and lock implementation.
Transactional Distributed Queue, Map, Set and List Posted: Oct 16, 2008 8:37 AM
Reply to this message Reply

This post originated from an RSS feed registered with Java Buzz by Talip Ozturk.
Original Post: Transactional Distributed Queue, Map, Set and List
Feed Title: Shared Memory
Feed URL: http://www.jroller.com/talipozturk/feed/entries/rss
Feed Description: about java, jcache, jini, javaspaces, distributed data structures and a little bit of me and life.
Latest Java Buzz Posts
Latest Java Buzz Posts by Talip Ozturk
Latest Posts From Shared Memory

Advertisement
Hazelcast, with its 1.3 release, is now transactional and as always it is super simple to use. Start a transaction, work with queues, maps, sets and do other stuff then commit/rollback in one shot.

import java.util.Queue;
import java.util.Map;
import java.util.Set;
import com.hazelcast.core.Hazelcast;
import com.hazelcast.core.Transaction; 

Queue queue = Hazelcast.getQueue("myqueue");
Map map     = Hazelcast.getMap  ("mymap");
Set set     = Hazelcast.getSet  ("myset");

Transaction txn = Hazelcast.getTransaction();
txn.begin();
try {	
	Object obj = queue.poll();
	//process obj
	map.put ("1", "value1");
	set.add ("value");
	//do other things..
	txn.commit();
}catch (Throwable t)  {
	txn.rollback();
}

Isolation is always READ_COMMITTED. If you are in a transaction, you can read the data in your transaction and the data that is already commit and if you are not in a transaction, you can only read the committed data. Implementation is different for queue and map/set. For queue operations (offer,poll), offered and/or polled objects are copied to the next member in order to safely commit/rollback. For map/set, Hazelcast first acquires the locks for the write operations (put, remove) and holds the differences (what is added/removed/updated) locally for each transaction. When transaction is set to commit, Hazelcast will release the locks and apply the differences. When rolling back, Hazelcast will simply releases the locks and discard the differences. Transaction instance is attached to the current thread and each Hazelcast operation checks if the current thread holds a transaction, if so, operation will be transaction aware. When transaction is committed, rolled back or timed out, it will be detached from the thread holding it.

This is a huge step forward for Hazelcast. It will continue its journey with listeners and events. Please visit Hazelcast Group page for complete list of planned features.

Read: Transactional Distributed Queue, Map, Set and List

Topic: Poll: What's Your Java Experience Level? Previous Topic   Next Topic Topic: PokyLinux vs OpenMoko

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use