Clustering-Transaction qn
1 posts in topic
Flat View  Flat View

Posted By:   neal_ravindran
Posted On:   Saturday, June 21, 2003 07:30 PM

If I have a stateless bean doing the DB access for an add/edit/delete method and I have that method under a "Required" transaction attribute ...and I have two app servers clustered.

Question is will, the access to the methods(in the 2 machines) be in a synchronized fashion(one at a time if more than one client request comes in...and the loadbalancer assigns the requests to 2 machines)? What clouds my mind is that the method is being invoked in 2 seperate JVMs...and there I suppose the clustering innards would help access be in a synchronized fashion....right?

Re: Clustering-Transaction qn

Posted By:   Nick_Maiorano  
Posted On:   Sunday, June 22, 2003 04:08 PM


It would be too complex and innefficient for any app server to synchronize access across a cluster. So the answer is: No, the app server does not synchronize method access of any EJB across a cluster.

Rather, you need to specify the isolation level of the transaction. Isolation levels predate EJBs and are specified in JDBC when you start a transaction. If you are using entity beans, they are specified inside the deployment descriptor and handled automatically by the ejb container. Essentially, they dictate how isolated each transaction is to each other. To achieve something similar to java's synchronized method semantics, you would use the SERIALIZABLE isolation level. With this, only one thread at a time is allowed to access the database. This gives you the least amount of concurrency since all other transactions block until the current one commits. At the other end of the spectrum is the read uncommitted which gives you the least amount of isolation but also the most speed.

There's more to it and you can take a look at the jdbc api here.

About | Sitemap | Contact