Situation
I have a jruby on rails app that has some long running processes that
can be called via a web interface.
The app is multthreading enabled so that several long running processes
can work at the same time - each in the thread that they were invoked
in.
I also have a thread monitor within the application that kills threads
if they run too long (i.e. they get stuck for some reason).
To ensure that the thread monitor watches the correct threads - each
long running process stamps its current thread with an id and time stamp
as such:
Thread.current[:id] = “some id”
Thread.current[:start_time] = Time.now
The thread monitor (which runs in a thread of its own) watches at 1
second intervals the threads that have an ID and a Time Stamp, as such
Thread.list.each {|thread| thread.kill if thread[:id] && thread[:id] ==
“some id” && Time.now - thread[:start_time] >= 5.minutes}
Complication
This all works fine when the app is started using jruby -S script/server
(i.e. with mongrel)
However, when I start the app using glassfish (either with the gem or as
a war file in the glassfish V3 prelude) I make the following
observation:
The app stamps Thread.current ok but the monitor see only a thread with
no id or start_time set and the object_ids of the thread are different.
Hypotheses
Mongrel starts an instance of my app using the ruby thread library.
Glassfish starts an instance of my app using the java.thread library.
It seems that I have no access to java current thread from my app, even
though the ruby library Thread.list can see it.
Question:
What do i need to do to get this working as expected.
any ideas would be very much appreciated.
Jason.
To unsubscribe from this list, please visit:
http://xircles.codehaus.org/manage_email