Spring 4.0 framework has an easy solution to this. Changed the Return type of the method DeferredResult . Create an instance of DeferredResult and assign whenever value is assigned to this instance it would return the response to calling request.
@RequestMapping(method=RequestMethod.GET)
public DeferredResult<String> getNewMessage(HttpServletRequest request, HttpServletResponse response)
{
DeferredResult<String> deferredResult = new DeferredResult<String>();
processRequest(deferredResult);
return deferredResult;
}
void processRequest( DeferredResult<String> result)
{
result.setResult("hello world");
}