About Tomcat NIO Connector, servlet 3.0 async, Spring MVC async Relationship

Source: Internet
Author: User

Tomcat's Org.apache.coyote.http11.Http11NioProtocol Connector is an asynchronous accept request that is implemented using Java NIO Connector

It does not need to establish a thread for each request, but instead uses a fixed accept thread to accept multiple requests and then queue up.

The idea is to use a fixed acceptthread to accept n requests, then queue the request, and finally use a fixed requestprocessingthread to process the business logic, and the processing of the business logic is actually synchronous

Http11nioprotocol support from Tomcat 6.x

Servlet 3.0 starts with the Tomcat 7.x, which makes the business process asynchronous, and the Spring 3.2 async becomes also based on the servlet 3.0来, for example

@ResponseBody @RequestMapping ("/{surl}")     PublicDeferredresult<responseentity<string>>Redirect (@PathVariable String surl) {FinalDeferredresult<responseentity<string>> dr =NewDeferredresult<responseentity<string>>(Timeout_ms, responseentityresult.timeout); // ... Do something asynchronously, and finally set the result to Deferredresult        NewThread (NewAsynctask (DR)). Start (); returnDr; }    Private Static classAsynctaskImplementsRunnable {PrivateDeferredresult result; Privateasynctask (deferredresult result) { This. result =result; } @Override Public voidrun () {//Business Logic// ...            //Set ResultsResult.setresult (Result); }    }

This way Tomcat's requestprocessingthread can be freed to handle other requests, and servlet-2.5 you can only process the final result, return it, and not put it on another thread.

About Tomcat NIO Connector, servlet 3.0 async, Spring MVC async Relationship

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.