We are using Websphere Work Manager
(CommonJ) for spawning threads in our application. We are making use of the default WorkManager
and through JNDI
accessing it in our application.
try {
Context ctx = new InitialContext();
wm = (WorkManager) ctx.lookup("java:comp/env/wm/App_WORKMANAGER");
wm.schedule(this);
//threadScheduler = new Thread(this);
//threadScheduler.start();
} catch (Exception e) {
// catch the exception
}
We keep running the threads which listens to different queues to check for any message and process it. We do get hung messages as below , came to know this can be configured from admin console to stop showing the warning/error or increase the hung detection time.
[1/30/13 6:50:38:708 EST] 00000032 ThreadMonitor W WSVR0605W: Thread "WorkManager.DefaultWorkManager : 2" (00000022) has been active for 708969 milliseconds and may be hung. There is/are 1 thread(s) in total in the server that may be hung.
Now if we stop the application from admin console, these thread don't get stopped and we keep getting the Hung messages. For another deployment another set of threads adds up to the Hung thread count.
I read somewhere that if we declare thread as Daemon
then they get stopped (). So is it fine that we declare the threads as Daemon
as below or we need to override the release()
method too? Our release()
is empty as of now.
public boolean isDaemon() {
return true;
}
public void release() {
//TODO
}
How exactly can we stop the application thread from running once the application is stopped? It's an old application using Struts 1.x
.
I read two explanation here:
Thread keeps running even after application has been stopped in Websphere (as I'm not using spring, just declaring
Deamon
is fine? And this will work if we stop the JVM itself, just stopping app from console wont help, correct?)Does Websphere respect Daemon threads? (the approach suggested by Sarel Botha is the only solution or we have some setting from console to get the job done.)
Thanks.