Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Servlet 3 @WebServlet & async with Spring MVC 3?

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?

like image 770
Ben Avatar asked Jul 27 '10 15:07

Ben


1 Answers

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.

like image 103
Krish Bheeman Avatar answered Oct 05 '22 06:10

Krish Bheeman