title: How to deal with a search task which takes more time than usual in Spring 3.0
body: <p>I am looking for ideas on how to deal with a search related task which takes more than usual time (in human terms more than 3 seconds)</p>
  
  <p>I have to query multiple sources, sift through information for the first time and then cache it in the DB for later quick return.</p>
  
  <p>The context of the project is J2EE, Spring and Hibernate (on top of SpringROO)</p>
  
  <p>The possible solutions I could think of 
  -On the webpage let the user know that task is running in background, if possible give them a queue number or waiting time. Refresh the page via a controller which basically checks if the task is done, then when its done (ie the search result is prepared and stored in DB) then just forward to a new controller and fetch the result from the DB</p>
  
  <p>-The background tasks could be done with Spring Task executor. I am not sure if it is easy to give a measure of how long it would take. It would probably be a bad idea to let all the search terms run concurrently, so some sort of pooling will be a good idea.</p>
  
  <p>-Another option to use background tasks is to use JMS. This is perhaps a solution with more control (retries etc)</p>
  
  <p>-Spring batch also comes to mind</p>
  
  <p>Please suggest how you would do it. I would greatly appreciate a semi-detailed+ description. The sources of info can be man and can be sequential in nature so it can take upto 4-5 minutes for the results to form. It is also possible that such tasks run automatically in the background without user intervention (ie to update from the sources)</p>