rubberbird / javapns

Automatically exported from code.google.com/p/javapns
0 stars 0 forks source link

Shutdown a PushQueue gracefully #168

Closed GoogleCodeExporter closed 8 years ago

GoogleCodeExporter commented 8 years ago
What steps will reproduce the problem?
1. Create your project using Tomcat
2. Create a NotificationThread in QUEUE mode
3. Shutdown the Tomcat service

What is the expected output? What do you see instead?
I expect to have a way to stop the underlying NotificationThread; instead, 
Tomcat reports that my Thread was left running, and will cause a memory leak.

What version of the product are you using? On what operating system?
Win7Pro SP1, JavaPNS Version 2.2, Tomcat 7

Please provide any additional information below.
The javadocs for the Thread class say we shouldn't use thread.stop(), either.  
We need more control over the underlying Thread object so we can shut things 
down gracefully.  I tried using NotificationThreads (subclass of ThreadGroup) 
to use setDaemon(true) and destroy(), but both of these options end up causing 
IllegalThreadStateException.  

I'm not sure why setDaemon(true) isn't working as expected (should cause them 
to be terminated with the Tomcat context), but perhaps it's because I was 
setting that on the ThreadGroup rather than directly on the Thread?  If I could 
have a handle on the underlying Thread I could set that manually; alternatively 
create more Thread-like methods on the NotificationThread class (e.g. 
setDaemon(boolean), stop()).  

Or change "private Thread thread" to "protected Thread thread".

Original issue reported on code.google.com by rthor...@gmail.com on 23 Feb 2013 at 12:58

GoogleCodeExporter commented 8 years ago
Note for future implementation:  
The PushQueue should be stoppable gracefully.  The runQueue method of 
NotificationThread (the actual implementation for PushQueue) actually has a 
switch for shutting down gracefully, but is not exposed to users.  A "stop" 
method should be added to the NotificationThread class, and it should simply 
set the mode property to something else than QUEUE, hence causing an exit of 
the runQueue method's primary while loop.

Original comment by sype...@gmail.com on 1 Mar 2013 at 5:37

GoogleCodeExporter commented 8 years ago
I would highly appreciate if this issue would be pushed to a higher priority. 
In production environment it can cause problems when you update the application 
several times with small bugfixes without restarting the whole tomcat 
environment. Thanks!

Original comment by andreas@filler.name on 26 Apr 2013 at 1:27

GoogleCodeExporter commented 8 years ago
Any updates on it?
I'm also afraid to run this on a production environment as it causes issues on 
every Tomcat shutdown.

Original comment by fred.sc...@gmail.com on 4 Jun 2013 at 12:31

GoogleCodeExporter commented 8 years ago
Is something like this what you had in mind?

Original comment by j...@relayrides.com on 26 Jul 2013 at 7:12

Attachments:

GoogleCodeExporter commented 8 years ago
I would really appreciate if something like in #4 would be implemented. Having 
trouble at Tomcat shutdown, too.

Original comment by cont...@vitus-lehner.de on 18 Jul 2014 at 10:51

GoogleCodeExporter commented 8 years ago
Fixed in r397 (trunk):  added a stopQueue() method to PushQueue, 
NotificationThread and NotificationThreads.

Original comment by sype...@gmail.com on 11 Oct 2014 at 9:18