It's not a secret anymore!
The moose likes EJB and other Java EE Technologies and the fly likes Pooled Connections - EJB Shutdown Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » EJB and other Java EE Technologies
Bookmark "Pooled Connections - EJB Shutdown" Watch "Pooled Connections - EJB Shutdown" New topic

Pooled Connections - EJB Shutdown

Stan James
(instanceof Sidekick)
Ranch Hand

Joined: Jan 29, 2003
Posts: 8791
We have a vendor framework that currently opens and closes an MQSeries connection for each request. We'd like to run a proof of concept pooling these connections to see if we get a useful performance gain. I have no problem making an object pool, but I'm concerned that at server shutdown we may leave a lot of connections open on the QueueManager end.

Is there a shutdown event in the EJB container that I can use as a trigger to close all the connections in my pool? Or a better idea entirely?

Do you know any specific MQ connection pooling solutions?

This is WebSphere 5.0.1, *not* Enterprise. I think some of this is built into the Enterprise version, but we're not there for some reason.

A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Valentin Tanase
Ranch Hand

Joined: Feb 17, 2005
Posts: 704
Hi Stan,

Without being a WAS expert I can provide you two hints: one is to use JMX and MBeans. I know you can develop listener classes that can listen for notification when the state of an MBean changes. For example you can locate any of the runtime MBeans and check whether the server is running or not. Another idea is to use a similar approach with the way the container implements connection pooling. In a nutshell you can write a simple method that checks if the connection is healthy and do the check in order to retrieve/return the connection to the pool. This way you can make sure that your clients get only available connections. I hope this will help.

I think, therefore I exist -- Rene Descartes
I agree. Here's the link:
subject: Pooled Connections - EJB Shutdown
jQuery in Action, 3rd edition