Parallel Processing on the Server

Discussions

Web tier: servlets, JSP, Web frameworks: Parallel Processing on the Server

  1. Parallel Processing on the Server (4 messages)

    I am creating a Java web application that demands some intense and time-consuming server-side processing. Therefore, once the user makes his request (which involves submitting a file), I want to do 2 things: 1) redirect the user to a confirmation page and 2)perform the processing and send an E-mail of the results to the user. Of course, these should be done in parallel.

    I am not exactly sure how to go about doing this sort of thing given the request/response model in servlets/JSPs. I've considered bouncing the reqest around various servlets to get this done, but I am not sure exactly how that would work. I've also considered spawning a thread, but I am not sure if I want to do that inside the web container.

    Any suggestions are greatly appreciated. Thanks.

    Threaded Messages (4)

  2. Parallel Processing on the Server[ Go to top ]

    What you could do is implement a Message Driven Bean that takes a message from your servlet and processes it. Basically, this could be your steps:

    - Servlet gets file from client and writes it "somewhere" with a random filename
    - The filename (instead of the file) is sent as a message to the MDB
    - Servlet returns response to client
    - MDB reacts to message, and processes the file any way you like

    This way the file is handled asynchronously from the client request. The reason for writing it to the file system is to avoid large messages (depending on the size of the file I guess).

    Just an idea, but it does what you want at least.
  3. Parallel Processing on the Server[ Go to top ]

    This ofcourse involves EJBs, so if you don't want to use that you basically have to do some thread handling yourself (or use some package that does it for you).
  4. Parallel Processing on the Server[ Go to top ]

    Thanks for your help. I am not terribly familiar with MDBs (though I am familiar with entity and session beans), so I could use some clarification. Are you suggesting queuing a message from the servlet to the MDB...with the MDB receiving the message and then processing the file and finally sending the E-mail?

    Any further insights are greatly appreciated. Thanks again.
  5. Parallel Processing on the Server[ Go to top ]

    Sorry for late reply. In short, yes, send the message to the queue/topic that your MDB is listening to from the servlet (and that send operation will exit as soon as the message is sent to the queue - not waiting for the MDB to react to it). A MDB will then be activated and handle the message put on the queue/topic.