aspose file tools*
The moose likes EJB and other Java EE Technologies and the fly likes how session beans service simultaneous client calls Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "how session beans service simultaneous client calls " Watch "how session beans service simultaneous client calls " New topic
Author

how session beans service simultaneous client calls

Alan Hermin
Ranch Hand

Joined: Feb 16, 2006
Posts: 290
Dears ..
I have a question about session beans(stateless/statefull):
if tow clients want access the same session beans,does the session beans service just one client , and when finish him, he will go to service the second one??.
rehards
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

In the case of stateless beans an instance serves each client call, it may or may not be the same instance, depending entirely on how the container responds. In the case of stateful beans, each client has its own instance, since the instance is tied to the session.


JavaRanch FAQ HowToAskQuestionsOnJavaRanch
Alan Hermin
Ranch Hand

Joined: Feb 16, 2006
Posts: 290
Dears..

in t he case of stateless session bean, it srvice each client call, when one client ends from the business method, the second one will be called..
right?

regards
[ October 02, 2007: Message edited by: Alaa Hendi ]
Paul Sturrock
Bartender

Joined: Apr 14, 2004
Posts: 10336

The container will serialize calls to each call to a session bean instance. Each session bean instance will see a serialized sequence of method calls; so yes if two clients call the same method on a stateless session bean and are directed to the same instance of that bean by the container then the second call will have to wait until the first call has completed.
Roger Chung-Wee
Ranch Hand

Joined: Sep 29, 2002
Posts: 1683
It is common to create and maintain a pool of stateless session bean instances. Each client call will be serviced by an available instance (usually in a separate thread). The instance will remain active until the end of the method call, after which the EJB container will unbind the session bean from the client and return the instance to the pool for reuse.

If the container has no available instances and is prevented from creating new ones, then all client calls for the EJB class will be blocked until an instance becomes available. However, should the block eventually cause a timeout, the container will throw RemoteException for a remote client or an EJBException for a local client.


SCJP 1.4, SCWCD 1.3, SCBCD 1.3
 
jQuery in Action, 2nd edition
 
subject: how session beans service simultaneous client calls