Author |
Message
|
Nikitich |
Posted: Wed Nov 23, 2011 12:18 am Post subject: How to gracefully shutdown connection pooling |
|
|
Newbie
Joined: 26 Jan 2010 Posts: 7
|
Hi,
Problem
When shutting down my app:
- that uses MQ v. 6.0.2.6 (both JMS and IBM MQ API client),
- deployed in Tomcat (6+),
- with Spring (3+),
- with MQSimpleConnectionManager for connection pooling, as the default one,
I am getting Tomcat's:
"SEVERE: The web application [...] appears to have started a thread named [PoolScavenger0] but has failed to stop it."
Questions
(a) How do I gracefully shutdown pool of connections in a servlet container?
(b) What could possibly be the reason of the hanging threads (originating from IBM MQ lib), eventually causing memory leak, as reported by Tomcat?
(c) What happens when there is a request in progress with a PoolToken in use, while admin shuts down web container?
I get my connection pool as follows:
- Created MQSimpleConnectionManager;
- Set it as the default one with MQEnvironment;
Thank you.
-
N |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Nov 23, 2011 11:02 am Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Sorry you got it all wrong. You should never mix the 2 java programming models. Either go all JMS, or go all java base.
And update at least to 6.0.2.10  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Nikitich |
Posted: Wed Nov 23, 2011 6:30 pm Post subject: |
|
|
Newbie
Joined: 26 Jan 2010 Posts: 7
|
fjb_saper,
Thank you for your input.
Will follow.
Code change, MQ FixPack/version update/upgrade however will take some time here to happen.
In the meantime it is an issue to deal with.
- Do you see a way to force the sockets to get closed; those originating from the pool?
I could probably live with the hanging Timer threads.
I'd prefer to avoid hanging connections affecting the server side.
I can get control prior to Tomcat's ultimate shutdown event.
Would it be possible to issue (to call MQ object's method) at that moment, something like:
- Whatever pool has been registered with MQEnvironment object, please shut it down and nicely ?
Thanks.
-
N. |
|
Back to top |
|
 |
fjb_saper |
Posted: Wed Nov 23, 2011 6:35 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
Nikitich wrote: |
fjb_saper,
Thank you for your input.
Will follow.
Code change, MQ FixPack/version update/upgrade however will take some time here to happen.
In the meantime it is an issue to deal with.
- Do you see a way to force the sockets to get closed; those originating from the pool?
I could probably live with the hanging Timer threads.
I'd prefer to avoid hanging connections affecting the server side.
I can get control prior to Tomcat's ultimate shutdown event.
Would it be possible to issue (to call MQ object's method) at that moment, something like:
- Whatever pool has been registered with MQEnvironment object, please shut it down and nicely ?
Thanks.
-
N. |
If you are on V7 you really should be on V7.0.1.6 (lots of fixes in JMS)
As for shutting down gracefully a connection pool, the only right and safe way I know is have the application that uses those connections release them correctly back to the pool, once it is done using them....
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Nikitich |
Posted: Wed Nov 23, 2011 7:14 pm Post subject: |
|
|
Newbie
Joined: 26 Jan 2010 Posts: 7
|
Good to know about v.7+, thanks.
My last one, I hope.
You mentioned earlier that mixing the two modes: JMS with IBM MQ Java API is not a good idea: "...You should never mix..."
Do you think that with v.7.0+ it is still true?
If 'Yes' - Why?
- the same product; no warnings in the RedBooks (have I missed them?)
Not asking for your extra time to explain; just few words.
Thank you.
-
N |
|
Back to top |
|
 |
fjb_saper |
Posted: Thu Nov 24, 2011 12:19 pm Post subject: |
|
|
 Grand High Poobah
Joined: 18 Nov 2003 Posts: 20756 Location: LI,NY
|
If you are using JMS you are hopefully in a J2EE environment and MQ JMS has been optimized for that environment. So why would you try and use Java base and rebuild the wheel to use it efficiently.
As for not mixing, the temptation is always great to use and object from java base in JMS or vice versa. This will not work. The two interfaces are not intermixable, though you might consider them to be interchangeable.
Have fun  _________________ MQ & Broker admin |
|
Back to top |
|
 |
Nikitich |
Posted: Sat Nov 26, 2011 6:56 pm Post subject: |
|
|
Newbie
Joined: 26 Jan 2010 Posts: 7
|
I had no issues with JMS based listeners.
It is just about the MQSimpleConnectionManager - the managing Timer thread left hanging, as well as pooled connections.
As a temporary solution I came to the following.
Prior to Tomcat getting shutdown I make the number of unused connection =0 and then set MQSimpleConnectionManager to MODE_INACTIVE.
No more hanging connections; I can live with the managing Timer thread on the client side for awhile.
fjb_saper, thank you. |
|
Back to top |
|
 |
|