共计 1362 个字符,预计需要花费 4 分钟才能阅读完成。
1、嵌入式 Reactive Web 容器
1.1、Webflux 概述
Webflux 模式替换了旧的 Servlet 线程模型。用少量的线程处理 request 和 response io 操作,这些线程称为 Loop 线程,而业务交给响应式编程框架处理,响应式编程是非常灵活的,用户可以将业务中阻塞的操作提交到响应式框架的 work 线程中执行,而不阻塞的操作依然可以在 Loop 线程中进行处理,大大提高了 Loop 线程的利用率。
1.2、Undertow 作为嵌入式 Reactive Web
修改 pom.xml 文件如下:
<!--<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-web</artifactId> | |
<exclusions> | |
<exclusion> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-tomcat</artifactId> | |
</exclusion> | |
</exclusions> | |
</dependency>--> | |
<!--webflux--> | |
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-webflux</artifactId> | |
</dependency> | |
<!--undertow--> | |
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-undertow</artifactId> | |
</dependency> |
1.3、Jetty 作为嵌入式 Reactive Web 容器
修改 pom.xml 文件,如下:
<!--webflux--> | |
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-webflux</artifactId> | |
</dependency> | |
<!--jetty--> | |
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-jetty</artifactId> | |
</dependency> |
1.4、Tomcat 作为嵌入式 Reactive Web 容器
<!--webflux--> | |
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-webflux</artifactId> | |
</dependency> | |
<dependency> | |
<groupId>org.springframework.boot</groupId> | |
<artifactId>spring-boot-starter-tomcat</artifactId> | |
</dependency> |
正文完
星哥玩云-微信公众号
