Storing the Remote Reference to a Stateless Session Bean. In an application with several Stateless Session EJB, we are debating the best approach with reference to performance on how to do the calls to our Stateless Session Beans.

Bozidar Dangubic

  1. Does it make sense to cache the reference we would get from using the EJBObject.getHandle(), then use this reference when attempting to access the bean from here on?
    - Absolutely.
  2. Does the reference map to a specific instance of the stateless session bean or to a pool of beans?
    - Since stateless session beans are all "created equal" most app servers using pooling to increase the performance. so the answer is that it maps to the pool of stateless session beans of the type for which you have the handle.
  3. Since session beans do not support concurrency is there a danger in having two threads utilize this same reference when accessing the stateless session bean? (does this depend on the container implementation?)
    - It does not depend on the application server implementation since there is no concurrency issues with stateless session beans. Concurrency problems occur when two or more threads operate on the same shared data in an unprotected way potentially resulting in loss of data integrity. Since your stateless session beans are stateless, there is no concurrency problems since there is no shared data to be corrupted. So no concurrency problems with stateless session beans.
  4. Is the overhead associated with the remote lookup on a stateless session bean enough to warrent keeping a handle on the reference?