Reactor Netty-响应式编程-010

 🤗 ApiHug × {Postman|Swagger|Api...} = 快↑ 准√ 省↓

  1. GitHub - apihug/apihug.com: All abou the Apihug   
  2. apihug.com: 有爱,有温度,有质量,有信任
  3. ApiHug - API design Copilot - IntelliJ IDEs Plugin | Marketplace

api-hug-contact

为什么不直接上来就 Netty 或者 Spring WebFlux ?

出于几点考虑:

  1. 本身 Netty 学习曲线稍微陡峭
  2. Spring WebFlux 封装很多细节

所以选择一个 Reactor --> Reactor Netty --> Spring WebFlux 这样一个渐进的线路。

Reactor Netty 官方文档open in new window,最新资料参考官网更新, 学习例子: reactor-netty-demo 学习open in new window

#关于

Suited for Microservices Architecture, Reactor Netty offers backpressure-ready network engines for HTTP (including Websockets), TCP, and UDP.

适合于微服务架构,Reactor Netty为HTTP(包括Websocket),TCP和UDP提供了支持背压的网络引擎。

#前提

Reactor Netty需要运行在Java 8 及以上的版本上。

它需要依赖于以下组件:

  1. Reactive Streams v1.0.4
  2. Reactor Core v3.x
  3. Netty v4.1.x

#项目依赖

都走BOM 走了非常简单:

dependencies {
  // import a BOM
  implementation platform('io.projectreactor:reactor-bom:2020.0.21') 

  // define dependencies without versions
  implementation 'io.projectreactor.netty:reactor-netty-core' 
  implementation 'io.projectreactor.netty:reactor-netty-http'
}

依赖关系如下:

------------------------------------------------------------
| BOM 依赖
------------------------------------------------------------
+--- io.projectreactor:reactor-bom:2020.0.21
|    +--- io.projectreactor.netty:reactor-netty-core:1.0.21 (c)
|    +--- io.projectreactor.netty:reactor-netty-http:1.0.21 (c)
|    +--- io.projectreactor:reactor-core:3.4.21 (c)
|    \--- org.reactivestreams:reactive-streams:1.0.4 (c)
------------------------------------------------------------
| 下面是具体版本
------------------------------------------------------------
+--- io.projectreactor.netty:reactor-netty-core -> 1.0.21
|    +--- io.netty:netty-handler:4.1.79.Final
|    |    +--- io.netty:netty-common:4.1.79.Final
|    |    +--- io.netty:netty-resolver:4.1.79.Final
|    |    |    \--- io.netty:netty-common:4.1.79.Final
|    |    +--- io.netty:netty-buffer:4.1.79.Final
|    |    |    \--- io.netty:netty-common:4.1.79.Final
|    |    +--- io.netty:netty-transport:4.1.79.Final
|    |    |    +--- io.netty:netty-common:4.1.79.Final
|    |    |    +--- io.netty:netty-buffer:4.1.79.Final (*)
|    |    |    \--- io.netty:netty-resolver:4.1.79.Final (*)
|    |    +--- io.netty:netty-transport-native-unix-common:4.1.79.Final
|    |    |    +--- io.netty:netty-common:4.1.79.Final
|    |    |    +--- io.netty:netty-buffer:4.1.79.Final (*)
|    |    |    \--- io.netty:netty-transport:4.1.79.Final (*)
|    |    \--- io.netty:netty-codec:4.1.79.Final
|    |         +--- io.netty:netty-common:4.1.79.Final
|    |         +--- io.netty:netty-buffer:4.1.79.Final (*)
|    |         \--- io.netty:netty-transport:4.1.79.Final (*)
|    +--- io.netty:netty-handler-proxy:4.1.79.Final
|    |    +--- io.netty:netty-common:4.1.79.Final
|    |    +--- io.netty:netty-buffer:4.1.79.Final (*)
|    |    +--- io.netty:netty-transport:4.1.79.Final (*)
|    |    +--- io.netty:netty-codec:4.1.79.Final (*)
|    |    +--- io.netty:netty-codec-socks:4.1.79.Final
|    |    |    +--- io.netty:netty-common:4.1.79.Final
|    |    |    +--- io.netty:netty-buffer:4.1.79.Final (*)
|    |    |    +--- io.netty:netty-transport:4.1.79.Final (*)
|    |    |    \--- io.netty:netty-codec:4.1.79.Final (*)
|    |    \--- io.netty:netty-codec-http:4.1.79.Final
|    |         +--- io.netty:netty-common:4.1.79.Final
|    |         +--- io.netty:netty-buffer:4.1.79.Final (*)
|    |         +--- io.netty:netty-transport:4.1.79.Final (*)
|    |         +--- io.netty:netty-codec:4.1.79.Final (*)
|    |         \--- io.netty:netty-handler:4.1.79.Final (*)
|    +--- io.netty:netty-resolver-dns:4.1.79.Final
|    |    +--- io.netty:netty-common:4.1.79.Final
|    |    +--- io.netty:netty-buffer:4.1.79.Final (*)
|    |    +--- io.netty:netty-resolver:4.1.79.Final (*)
|    |    +--- io.netty:netty-transport:4.1.79.Final (*)
|    |    +--- io.netty:netty-codec:4.1.79.Final (*)
|    |    +--- io.netty:netty-codec-dns:4.1.79.Final
|    |    |    +--- io.netty:netty-common:4.1.79.Final
|    |    |    +--- io.netty:netty-buffer:4.1.79.Final (*)
|    |    |    +--- io.netty:netty-transport:4.1.79.Final (*)
|    |    |    \--- io.netty:netty-codec:4.1.79.Final (*)
|    |    \--- io.netty:netty-handler:4.1.79.Final (*)
|    +--- io.netty:netty-resolver-dns-native-macos:4.1.79.Final
|    |    \--- io.netty:netty-resolver-dns-classes-macos:4.1.79.Final
|    |         +--- io.netty:netty-common:4.1.79.Final
|    |         +--- io.netty:netty-resolver-dns:4.1.79.Final (*)
|    |         \--- io.netty:netty-transport-native-unix-common:4.1.79.Final (*)
|    +--- io.netty:netty-transport-native-epoll:4.1.79.Final
|    |    +--- io.netty:netty-common:4.1.79.Final
|    |    +--- io.netty:netty-buffer:4.1.79.Final (*)
|    |    +--- io.netty:netty-transport:4.1.79.Final (*)
|    |    +--- io.netty:netty-transport-native-unix-common:4.1.79.Final (*)
|    |    \--- io.netty:netty-transport-classes-epoll:4.1.79.Final
|    |         +--- io.netty:netty-common:4.1.79.Final
|    |         +--- io.netty:netty-buffer:4.1.79.Final (*)
|    |         +--- io.netty:netty-transport:4.1.79.Final (*)
|    |         \--- io.netty:netty-transport-native-unix-common:4.1.79.Final (*)
|    \--- io.projectreactor:reactor-core:3.4.20 -> 3.4.21
|         \--- org.reactivestreams:reactive-streams:1.0.4
------------------------------------------------------------
| HTTP
------------------------------------------------------------
+--- io.projectreactor.netty:reactor-netty-http -> 1.0.21
|    +--- io.netty:netty-codec-http:4.1.79.Final (*)
|    +--- io.netty:netty-codec-http2:4.1.79.Final
|    |    +--- io.netty:netty-common:4.1.79.Final
|    |    +--- io.netty:netty-buffer:4.1.79.Final (*)
|    |    +--- io.netty:netty-transport:4.1.79.Final (*)
|    |    +--- io.netty:netty-codec:4.1.79.Final (*)
|    |    +--- io.netty:netty-handler:4.1.79.Final (*)
|    |    \--- io.netty:netty-codec-http:4.1.79.Final (*)
|    +--- io.netty:netty-resolver-dns:4.1.79.Final (*)
|    +--- io.netty:netty-resolver-dns-native-macos:4.1.79.Final (*)
|    +--- io.netty:netty-transport-native-epoll:4.1.79.Final (*)
|    +--- io.projectreactor.netty:reactor-netty-core:1.0.21 (*)
|    \--- io.projectreactor:reactor-core:3.4.20 -> 3.4.21 (*)

#参考

  1. Reactor Netty 官方文档open in new window
  2. reactor-netty-demo 学习open in new window
  3. Reactor Netty Workshopopen in new window
  4. reactor-netty API

相关推荐

  1. Vue的响应编程

    2024-05-04 02:26:03       63 阅读
  2. 响应编程-数据劫持

    2024-05-04 02:26:03       26 阅读
  3. 编程笔记 html5&css&js 060 css响应布局

    2024-05-04 02:26:03       45 阅读
  4. 响应编程Reactor API大全(中)

    2024-05-04 02:26:03       43 阅读

最近更新

  1. docker php8.1+nginx base 镜像 dockerfile 配置

    2024-05-04 02:26:03       94 阅读
  2. Could not load dynamic library ‘cudart64_100.dll‘

    2024-05-04 02:26:03       101 阅读
  3. 在Django里面运行非项目文件

    2024-05-04 02:26:03       82 阅读
  4. Python语言-面向对象

    2024-05-04 02:26:03       91 阅读

热门阅读

  1. React 之 如何启动一个新的项目(六)

    2024-05-04 02:26:03       31 阅读
  2. python - mac安装mysqlclient

    2024-05-04 02:26:03       26 阅读
  3. 一步一步写线程之十一线程池应用内存池

    2024-05-04 02:26:03       33 阅读
  4. css实现瀑布流布局

    2024-05-04 02:26:03       32 阅读
  5. matlab绘制散点图

    2024-05-04 02:26:03       36 阅读
  6. L1-042 日期格式化

    2024-05-04 02:26:03       27 阅读
  7. 概述小样本学习的具体应用场景

    2024-05-04 02:26:03       32 阅读
  8. 寻找自己的25号底片

    2024-05-04 02:26:03       36 阅读
  9. 上海计算机学会2023年9月月赛C++丙组T1口令的分类

    2024-05-04 02:26:03       34 阅读
  10. 238. 除自身以外数组的乘积/41. 缺失的第一个正数

    2024-05-04 02:26:03       29 阅读