Two Laptop Bag*
The moose likes EJB and other Java EE Technologies and the fly likes multiple clients accessing entity beans Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "multiple clients accessing entity beans" Watch "multiple clients accessing entity beans" New topic
Author

multiple clients accessing entity beans

krishna prasad gunasekaran
Ranch Hand

Joined: Jul 25, 2006
Posts: 158
i have read that the container synchronizes the bean with the underlying storage by calling the bean's ejbLoad() and ejbStore(), to ensure the clients that the data they access and process in the business method, is not stale.

this is the sequence ejbLoad()-business method-ejbStore().
let's have a two-client-scenario where we have two entity bean instances.

bold ones are methods used by first client.

first client

(1)ejbLoad()--(2)business method

second client comes in to the picture, while the data is still being processed by the first client

(3)ejbLoad()

first client stores the data in to db

(4)ejbStore()

won't the data the second client is about to process goes stale?
How the container solves the problem? or is this a problem at all?


have a great day,
krishna prasad
Amit M Tank
Ranch Hand

Joined: Mar 28, 2004
Posts: 257
You are talking about concurrency. J2EE servers provides mechanism to handle concurrency, you can have a concurrency strategy, like exclusive, databse, optimistic etc. Please read the article


Amit Tank
Linked In
krishna prasad gunasekaran
Ranch Hand

Joined: Jul 25, 2006
Posts: 158
thank you amit,
my question has been addressed in that article, but not solved. the author has mentioned that this is the only issue we face when employing 'database concurrency' and a solution is yet to be found.
Amit M Tank
Ranch Hand

Joined: Mar 28, 2004
Posts: 257
Yes the data gets stale but when you are trying to do a commit the container can check for the data to be stale(may be by calling load again) and throw an EJBException(concurrency exception) if you have configured database concurrency strategy in your server. We used this for EJB2.x with weblogic. I am not sure if other servers provides similar mechanism.

Thanks,
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: multiple clients accessing entity beans
 
Similar Threads
ejbLoad and ejbStore
Doubt on the level of lock and concurency
A basic Question on ejbLoad and ejbStore
ejbLoad() and ejbStore()
CMP Beans and Jboss4.0.4Ga for Concurent requests