Note that there are some explanatory texts on larger screens.

plurals
  1. POSolution to the long running query problem in a web application (asynchronous request)
    primarykey
    data
    text
    <p>Here is the problem</p> <p>A user of an enterprise web application is performing a task that results in a long (very long) database query (or other long processing intensive task)</p> <p>Problems:</p> <ul> <li>Request timeout - after a while the user may get a request timeout</li> <li>Session timeout - if no session keeping methods are used, a session timeout can occur</li> <li>Request thread lock <ul> <li>since the request thread is not returning, it may block new requrests (if reaches the pool limit) </li> <li>In some application servers the server's health status might trigger a forced restart of the node or application(due to a long running request thread)</li> </ul></li> <li>If the user leaves the page: <ul> <li>the transaction is not canceled - resulting in useless processing no one will benefit from</li> <li>the user can't return to see the results after they complete </li> </ul></li> <li>no progress indication - the user just waits for the page to refresh</li> </ul> <p>There are several solutions I came up with, but I'm not sure I know which is better (in all aspects, peformance, best practice, elegance and maintainability) and I would like to know what is your recommended solution, and if there is a solution that I missed? (probably yes, and many)</p> <p><strong>The bad solution</strong>: use the request thread as a worker thread,save progress state in the session, have an AJAX call check the status (in the session) in another paralel request</p> <p><strong>The compromise solution</strong>: create your own thread pool, handle a monitoring thread, a worker thread and take care of clustering by syncronizing the states in either a distrubuted transactional cache or persistant storage. this releases the request, but creats threads the application server is not aware of, and won't close in undeployment. Its up to you to shutdown threads in a clean way, and there is always a chance you will end up leaking something. This is not the J2EE way to do it either.</p> <p><strong>The J2EE solution</strong>: use JMS for the asynchronous task, this is what it's ment for</p> <p><strong>the Spring solution</strong>: use Spring batch </p> <p>What would you do / did in your projects? What other solutions you know? which of the ones I noted above is the winner in your opinion?</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload