Discussions

EJB programming & troubleshooting: How to check server status for per client

  1. How to check server status for per client (3 messages)

    Suppose, one client sends one request to the server, and the server will take 5 minutes to deal with this request.
    During this 5 minutes, we hope that the client can see some other information, not just waiting for server's response.
    When server has done this transaction, the server sends the result page to the client.
    How to do this?
    Thanks by advance!
    Colin He
  2. Check out whether a JMS/Asynchronous Messaging based architecture fits you.

    > Suppose, one client sends one request to the server, and > the server will take 5 minutes to deal with this request.

    Since the server takes 5 minutes (or whatever) to deal with the request, the client *should not* be waiting for a response. So, make this request asynchronous - by putting the request on a message queue. A RequestProcessing MDB (Message-Driven Bean) would be assigned by the container to do the actual processing of the request.

    When the processing is done, the RequestProcessingMDB puts the result out on another queue which in turn triggers a call to a ResultProcessing MDB. This ResultProcessing MDB now sets a flag of some sort (either on HttpSession, or SFSB or database.) saying that the request is successful - say a "ProcessingComplete" flag. It could even store the result on the session (or bean), if the result-set is small enough.

    > During this 5 minutes, we hope that the client can see
    > some other information, not just waiting for server's
    > response.

    In the meantime (while the RequestProcessing MDB is in action), the appserver returns some other page (showing whatever information you need). Every new request that the user makes from then on checks to see if the original request has been satisfied - by checking for the "ProcessingComplete" flag that will be set.

    > When server has done this transaction, the server sends
    > the result page to the client.

    As I mentioned before, when the server is done with its transaction, it sets the "ProcessingComplete" flag. The next client request would return "true" for the flag and you need to take necessary action to retrieve and present the "result" to the client.

    > How to do this?

    What I described above is one way of doing it. There are several other ways of doing it - it all depends on what architecture you are constrained by. If you can use JMS/MQ it will make your task easier.

    Hope this helps,
    --Das
  3. Hello, Das:
    JMS/Asynchronous is a good architecture, can you help find some example code for this scenario?
    Or can we solve this problem by servlet-based solution? if we can, how to do?
    Best Regards!
    Yihua, He
  4. I don't have any sample code as such. Why don't you check one of the appserver/vendor sites for that? BEA's site has some good documentation/code.

    --Das