Hi,
I've done some tests with the spring mvc's async functionality and it doesn't work as expected. The tests have been done with the spring-mvc-showcase application and deployed on Tomcat 7.0.34.
For simplicity I've limited the number of Tomcat's threads to 5:
The service "/async/callable/response-body" returns a callable and another thread (managed by Spring MVC, not Tomcat) executes the call method. This method sleeps for 2 seconds and returns a String.Code:<Connector connectionTimeout="20000" maxThreads="5" minThreads="5" port="8080" protocol="HTTP/1.1" redirectPort="8443"/>
If I do 10 requests to "/async/callable/response-body" path in less than 2 seconds, all the requests should be attended by Tomcat's threads because they don't execute the sleep method. If have understood correctly, the Spring managed threads would be sleeping and Tomcat's threads ready to receive more requests.Code:@RequestMapping("/response-body") public @ResponseBody Callable<String> callable() { return new Callable<String>() { @Override public String call() throws Exception { Thread.sleep(2000); return "Callable result"; } }; }
However in the tests I've done, the last 5 requests are queued in Tomcat until the first five requests are completed.
Have I missed something?
Thanks in advance.


Reply With Quote
