Stateless EJB and JDBC connection pooling
843829Apr 23 2002 — edited Apr 25 2002We are using Stateless EJBs and passing around value beans (simple beans with properties, and almost no code) between the clients and the statless EJBs. The stateless EJBs then persist these value beans etc...
The problem is due to the fact that we are using connection pooling to get and release JDBC connections at the start and finish of each method in the EJB.
This works great (and is recommended) if the EJB method is fully self contained. The problem occurrs when an EJB method wants to call another ejb method. The call to the other method then gets an ADDITIONAL connection from the pool to do some work (and returns it at the end). This becomes a problem with several layers of nesting, as for a short instance of time, serveral connections maybe used to service a single call.
We have found that this can limit scalability under heavy (simlulated) concurrent usage, as there are a finite number of threads.
I have thought that using a single connection for an entire ejb instance (using ejbCreate and ejbRemove callbacks to obtain and release them) could be a solution. Are there any issues with using a single connection object like this? one issue could be that for each instance of the stateless bean a connection is held (means we have to restrict ejb instances).
Please help !!