[jboss-user] [JBossCache] - Re: Query related to jboss cache transaction
arif.mohammed1@wipro.com
do-not-reply at jboss.com
Tue Jan 15 08:56:20 EST 2008
Hi manik,
Iam newbie to jboss cache, Please clarify me regarding my understanding.
I am using the POJO cache in clustered environment as follows.
public class POJO{
private int count;
private setCount(int count){
this.count = count;
}
private int getCount(){
return count;
}
}
A POJO object will be created and attached to the cache through a servlet in instance1 as follows
POJO obj = new POJO();
cache = PojoCacheFactory.createCache("replSync-service.xml", true);
cache.attach("monitor", obj); // I hope "/monitor" will be the FQN under which obj will be stored
Now 2 transactions t1,t2 will be trying to increment the value of count from instance2,instance3 respectively as follows
cache = PojoCacheFactory.createCache("replSync-service.xml", true);
POJO obj = (POJO) cache.find("monitor");
tx.begin();
int currentValue = obj.getCount();
currentValue++;
obj.setCount(currentValue);
tx.commit();
Now how can i guarantee that the count value is not over written by t2 which was written by t3
Can i acquire explicit lock on "/monitor" before starting a transaction so that no other transaction in other instance should be able to read/write on "/monitor" ?
Iam expecting that if isolation level "SERIALIZABLE" is used i don't need to bother about the above problem and repeat the statements in between begin,commit untill it succeeds. Am i right ?
View the original post : http://www.jboss.com/index.html?module=bb&op=viewtopic&p=4120091#4120091
Reply to the post : http://www.jboss.com/index.html?module=bb&op=posting&mode=reply&p=4120091
More information about the jboss-user
mailing list