EJB Performance Tuning

Cache Bean-Specific Resources

Use the setMessageDrivenContext() or ejbCreate() method to cache bean specific resources, and release those resources from the ejbRemove() method.

Limit Use of JMS Connections

When designing an application that uses JMS connections make sure you use a methodology that sparingly uses connections, by either pooling them or using the same connection for multiple sessions.

The JMS connection uses two threads and the sessions use one thread each. Since these threads are not taken from a pool and the resultant objects aren’t pooled, you could run out of memory during periods of heavy usage.

One workaround is to move createTopicConnection into the init of the servlet.

Make sure to specifically close the session, or it will stay open, which ties up resources.

48

Sun GlassFish Enterprise Server 2.1 Performance Tuning Guide • January 2009

Page 48
Image 48
Sun Microsystems 820434310 manual Cache Bean-Specific Resources, Limit Use of JMS Connections