I would like to integrate the servlet 3.0 async support with spring MVC. Something like:
@RequestMapping("/chat")
@WebServlet(name="myServlet", asyncSupported=true)
public String getMessage(String userName) {
......
}
is it possible?
Not so fast, it is not that easy to implement good long polling. The method you mentioned works well, but there is a serious issue of "thread starvation"
Each Long polling will use up one thread, if you have 1000 concurrent user you would need 1000 thread to service the long polling request ( which most of the time does update of the server side status on the client browser)
Jetty 6 has a continue pattern whcih cleverly releases the thread of long polling request to be used by rhe real application logic.