Spawning Thread in ServletContainer

Discussions

General J2EE: Spawning Thread in ServletContainer

  1. Spawning Thread in ServletContainer (3 messages)

    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.

    Threaded Messages (3)

  2. Spawning Thread in ServletContainer[ Go to top ]

    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
  3. Spawning Thread in ServletContainer[ Go to top ]

    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.
  4. Spawning Thread in ServletContainer[ Go to top ]

    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)