Hi Everyone,
I have an existing application that allows users to submit reports to be processed in the background. When the report is completed I dump it into a database, then send the user a message that the report is completed.
To accomplish this I have been spawning off a Thread for each report and although this is a hack, it has worked well. Up until the time we tried to port this app to a new server version (WAS 5.1 -> WAS6.0).
What I'd like to know is what is the proper way to accomplish this without holding up the user's browser? These reports can take several minutes to complete.
I do not have any EJB experience, but I'm assuming that my solution may lie in that realm.
Any help is much appreciated.
-
Spawning Thread in ServletContainer (3 messages)
- Posted by: Jim McLean
- Posted on: February 22 2006 11:51 EST
Threaded Messages (3)
- Spawning Thread in ServletContainer by Chris Johnson on February 22 2006 16:10 EST
- Spawning Thread in ServletContainer by Jim McLean on February 24 2006 09:20 EST
- Spawning Thread in ServletContainer by Jeryl Cook on February 26 2006 22:21 EST
-
Spawning Thread in ServletContainer[ Go to top ]
- Posted by: Chris Johnson
- Posted on: February 22 2006 16:10 EST
- in response to Jim McLean
WebSphere App Server strongly discourages you from creating threads. I don't believe that the web container will prohibit you from doing this, but it is currently unsupported....
From the Servlet 2.3 spec section SRV.9.11:
"Such servlet containers should support this behavior when performed on threads created by the developer, but are not currently required to do so. Such a requirement will be added in the next version of this specification. Developers are cautioned that depending on this capability for application-created threads is nonportable."
Luckily, WAS gives you two mechanisms to do this safely; Asynchronous Beans and the Commonj WorkManager...
Here's a link:
http://publib.boulder.ibm.com/infocenter/wasinfo/v6r0/topic/com.ibm.websphere.base.doc/info/aes/ae/welc6tech_asb.html -
Spawning Thread in ServletContainer[ Go to top ]
- Posted by: Jim McLean
- Posted on: February 24 2006 09:20 EST
- in response to Chris Johnson
Thanks for the info Chris.
Ya, I knew I was hacking... but sometimes it has to be done. :)
I'll check out that WorkManager stuff. -
Spawning Thread in ServletContainer[ Go to top ]
- Posted by: Jeryl Cook
- Posted on: February 26 2006 22:21 EST
- in response to Chris Johnson
please take Chris advice, i saw this post from my reader, and was about to write the exact same thing...
Don't use threads in servlets ever..we just finished re-writing an entire application because previous developers used threads throughout the app creating memory leaks,etc.
HOWEVER,
i found using Qaurtz JObs for thread like functionality.(if u dont have MDBs)