Hi Gopal,
Can anybody tell me, if N number of clients accessing the ejb stateless session bean then how many instances will be created???
The number of SLSB instances doesn�t depend upon the number of clients accessing the ejb. It has everything to do with the way the pool is configured. Most containers provide special deployment descriptor tags that like
initial-beans-in-free-pool and
max-beans-in-free-pool. The way it works is pretty intuitive: when starting up, the server automatically creates exactly
initial-beans-in-free-pool beans in the pool. As the number of client requests grows, it will increase the pool up to
max-beans-in-free-pool. If a client needs to access the bean and no instances are available the transaction will block until either a bean instance becomes available or the transaction times out.
whether it will for different bean like statless, stateful, entity bean,
Well for SFSB there is no pooling involved and in theory the number of SFSB should be equal with the number of clients accessing them. That�s not always the case because some containers might chose to take a step further and cache them. Weblogic for example maintains a cache of SFSBs and the server allows configuring the cache in a similar (but not at all identical) way the SLSB free pool is configured. The cache is internally managed using either an LRU or NRU algorithm for passivating the beans.
Entity beans on the other hand are even more complicated because the container always pools the bean instances (as per EJB specs) but it can also cache them. The difference is that the beans in the pool are not associated with any clients, while beans in the cache have always an identity (a primary key) and are associated with clients. The server allow configuring the
max-beans-in-cache.
So as you can see there is no straight answer to how many bean instances the container creates. It could be quite different depending upon the type of container or the type of settings allowed.
Regards.