Asynchronous Search JMS with MDB
And the process flow will normally as followed:
1) put request on sending queue
2) expect response from receiving queue
Since JMS is designed to be asynchronous, it is not good to have the synchronous servlet waiting for response from receiving queue while holding the resource.
What i mean by synchronous servlet is a single servlet put request and waiting for response in a doGet or do Post method. In this way, the server resource will be holding while still waiting for the response. If the response take long time to return, this eventually will lower the application server performace.
The solution in short :
1) Servlet to put request on sending queue and return to jsp after put request
2) In JSP, using either META tag or javascript to refresh the page every n second
3) When page is refresh, send request to another servlet that check the queue/DB for the response.
3a) Can also used MDB to listen on receiving queue, and insert record to DB directly after receive response. Then when servlet check can directly check the db.
4) If response is still not yet ready, return back to the jsp again
5) If response is ready, forward to another jsp that display the result.
For Full Details, please visit the Asynchronous queries in J2EE