diff --git a/spring/webflux/spring webflux.md b/spring/webflux/spring webflux.md index c13f48f..fd139bd 100644 --- a/spring/webflux/spring webflux.md +++ b/spring/webflux/spring webflux.md @@ -33,3 +33,150 @@ Spring webflux提供了如下两种编程模型: #### 调用阻塞api 当想要在webflux中使用阻塞api时,可以按如下方式进行使用。`RxJava`和`Reactive`都支持`publushOn`操作,其支持在另一个线程中`继续执行`。 +## Reactive Core +`spring-web`对于reactive web应用具有如下支持: +- 对于server request的处理,拥有如下两种级别的支持: + - `HttpHandler`: 基于`non-blocking I/O`和`Reactive Stream back pressure`,适配`Reactor Netty, Undertow, Tomcat, Jetty以及任一Servlet Container + - `WebHandler`:稍高级别的、通用的web api,用于请求处理,在此基础上构建基于`annotated controllers`和`functional endpoints`的编程模型 +- 对于client端,`ClientHttpConnector`用于发送http请求,同时兼容`非阻塞io和Reactive Stream back pressure` +- codecs用于客户端和服务端的序列化和反序列化 + +### HttpHandler +HttpHandler中只通过一个单独的方法来处理请求和相应,其对不同的http server api进行了最小化的抽象。 + +下表描述了支持的api: +
| Server name | +Server API used | +Reactive Streams support | +
|---|---|---|
Netty |
+Netty API |
++ |
Undertow |
+Undertow API |
+spring-web: Undertow to Reactive Streams bridge |
+
Tomcat |
+Servlet non-blocking I/O; Tomcat API to read and write ByteBuffers vs byte[] |
+spring-web: Servlet non-blocking I/O to Reactive Streams bridge |
+
Jetty |
+Servlet non-blocking I/O; Jetty API to write ByteBuffers vs byte[] |
+spring-web: Servlet non-blocking I/O to Reactive Streams bridge |
+
Servlet container |
+Servlet non-blocking I/O |
+spring-web: Servlet non-blocking I/O to Reactive Streams bridge |
+
| Server name | +Group id | +Artifact name | +
|---|---|---|
Reactor Netty |
+io.projectreactor.netty |
+reactor-netty |
+
Undertow |
+io.undertow |
+undertow-core |
+
Tomcat |
+org.apache.tomcat.embed |
+tomcat-embed-core |
+
Jetty |
+org.eclipse.jetty |
+jetty-server, jetty-servlet |
+