aspose file tools*
The moose likes Architect Certification (SCEA/OCMJEA) and the fly likes stateful bean can be pooled or not? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Java 8 in Action this week in the Java 8 forum!
JavaRanch » Java Forums » Certification » Architect Certification (SCEA/OCMJEA)
Bookmark "stateful bean can be pooled or not?" Watch "stateful bean can be pooled or not?" New topic
Author

stateful bean can be pooled or not?

Win Yu
Ranch Hand

Joined: Oct 17, 2001
Posts: 224
stateful bean can be pooled or not?


Win
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
There is nothing technically stopping a Stateful Session EJB from being pooled but it does not make sense to do so. Pooling will not offer any advantages since the state of the EJBObject would need to be passivated to place it back in the pool. Rather than helping performance, this would hinder performance. For this reason Stateful Session EJBs are not pooled by any Application Server that I know of.
Win Yu
Ranch Hand

Joined: Oct 17, 2001
Posts: 224
I read Master EJB and got a impression that stateful session bean can be out in instance pool,but the Enterprise Javabean said it can't be pooled. I am a little confused there. can you one give the good explaination? thanks.
Robin Zhang
Ranch Hand

Joined: Apr 11, 2002
Posts: 139
stateful bean can not pooled as per EJBs book.
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
Stateful Session Beans can be pooled. They just have to be treated differently then Stateless Session Beans. This is why there is a way to passivate and activate a Stateful Session Bean. Passivation/Activation is expensive and the Container definitely desires to passivate and activate as little as possible.
Kartik Shah
Ranch Hand

Joined: Dec 07, 2000
Posts: 102
"Stateful Session Bean are dedicated to one client for their entire life, so there is no swapping or pooling of instances. Instead of pooling instances, stateful session beans are simply evicted from memory to conserve resources. ... This means that a stateful bean must be passivated beforeit is evicted to preserve the conversational state of the instance, and it must be activated to restore the state when the EJB object becomes active again."
Page 266 Chapter 7 Session Bean Richard Monson Haefel


Kartik Shah
SCJP, SCDJWS, IBM Certified Websphere & XML, PMP & Six Sigma - http://blog.kartikshah.info
Chris Mathews
Ranch Hand

Joined: Jul 18, 2001
Posts: 2712
I hate to play the quote game but when you do, go straight to the source.
Enterprise JavaBeans 2.0 Specification:

The container manages the life cycle of the session bean instances. It notifies the instances when bean action may be necessary, and it provides a full range of services to ensure that the session bean implementation is scalable and can support a large number of clients.

and

To efficiently manage the size of its working set, a session bean container may need to temporarily transfer the state of an idle stateful session bean instance to some form of secondary storage.

Hey guys this is what is commonly known as resource pooling. No where does it state that these actions are restricted to stateless session beans only.
Now a quote from Mastering EJB:

EJB does indeed support the effect of pooling stateful session beans. Only a few instances can be in memory when there are actually many clients. But this pooling effect does not come for free - the passavation/activation steps could entail an input/output bottleneck. Contrast this to stateless session beans, which are easily pooled because there is no state to save.

[ April 18, 2002: Message edited by: Chris Mathews ]
Robin Zhang
Ranch Hand

Joined: Apr 11, 2002
Posts: 139
Chris,
sometime the book ,"Master EJB", is confusing. From life cycle of stateful beans, it is difficult to understand how stateful beans get pooled.
By the way, maybe EJB1.1 and EJB2.0 are different.
Kartik Shah
Ranch Hand

Joined: Dec 07, 2000
Posts: 102
1. Does Container manages instances of stateful session bean and assigns instance as and when request comes ?
2. Does the passivated instance of the bean is used to serve the other requests ?
My answer to both is "No".
Hence I do not think that stateful session Bean are "POOLED".
Passivating Stateful session bean reduces the memory utilization on the server. I think it does not indicates that the passivated instance of the bean is re-used to serve another request.
Let's Discuss.
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: stateful bean can be pooled or not?
 
Similar Threads
Pooling Stateful Session Bean
Stateful bean and instance pooling
What does the JNDI lookup return?
MultiThreaded Bean
Pooling Stateful Session Bean