https://issues.apache.org/bugzilla/show_bug.cgi?id=56184
Bug ID: 56184
Summary: Async servlet doesn't work asyncroniously
Product: Tomcat 7
Version: 7.0.50
Hardware: PC
Status: NEW
Severity: normal
Priority: P2
Component: Connectors
Assignee: [email protected]
Reporter: [email protected]
Also tested at Tomcat 8.03
In apache-tomcat-7.0.50 I've changed connector according
http://blog.yamanyar.com/2013/09/dont-forget-to-use-nio-if-you-are-doing.html
Async servlet is very simple:
@WebServlet(asyncSupported = true, value = "/sendMailAsync")
public class SendMailServletAsync extends SendMailServlet {
private static final ExecutorService EXE = Executors.newFixedThreadPool(500);
@Override
protected void doProcess(HttpServletRequest request, HttpServletResponse
response, Map<String, String> params) throws IOException, ServletException {
final AsyncContext ac = request.startAsync(); // obtain async context
Runnable worker = new Runnable() {
@Override
public void run() {
try {
Thread.sleep(5000); // wait 5 sec
logger.info("Finish");
} catch (Exception e) {
logger.error("Exception during process async request", e);
} finally {
ac.complete();
}
}
};
EXE.execute(worker);
logger.info("Async request in progress");
}
Test was done by apache ab
Results for sync and async servlets is the same:
Requests per second: 19.68 [#/sec] (mean)
--
You are receiving this mail because:
You are the assignee for the bug.
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]