reactor netty
v1.2.1
Reactor Netty
提供基于Netty
框架的非阻塞和背压就绪的TCP
/ HTTP
/ UDP
/ QUIC
客户端和服务器。
Reactor Netty
需要 Java 8 或 + 才能运行。
使用 repo.spring.io 或Maven Central
存储库中的Gradle
(仅限稳定版本):
repositories {
// maven { url 'https://repo.spring.io/snapshot' }
maven { url ' https://repo.spring.io/milestone ' }
mavenCentral()
}
dependencies {
// compile "io.projectreactor.netty:reactor-netty-core:1.2.2-SNAPSHOT"
compile " io.projectreactor.netty:reactor-netty-core:1.2.1 "
// compile "io.projectreactor.netty:reactor-netty-http:1.2.2-SNAPSHOT"
compile " io.projectreactor.netty:reactor-netty-http:1.2.1 "
}
有关获取它的更多信息,请参阅参考文档(例如,使用Maven
或如何获取里程碑和快照)。
Reactor Netty
新手?查看 Reactor Netty Workshop 和参考文档
这是一个非常简单的HTTP
服务器和相应的HTTP
客户端示例
HttpServer . create () // Prepares an HTTP server ready for configuration
. port ( 0 ) // Configures the port number as zero, this will let the system pick up
// an ephemeral port when binding the server
. route ( routes ->
// The server will respond only on POST requests
// where the path starts with /test and then there is path parameter
routes . post ( "/test/{param}" , ( request , response ) ->
response . sendString ( request . receive ()
. asString ()
. map ( s -> s + ' ' + request . param ( "param" ) + '!' )
. log ( "http-server" ))))
. bindNow (); // Starts the server in a blocking fashion, and waits for it to finish its initialization
HttpClient . create () // Prepares an HTTP client ready for configuration
. port ( server . port ()) // Obtains the server's port and provides it as a port to which this
// client should connect
. post () // Specifies that POST method will be used
. uri ( "/test/World" ) // Specifies the path
. send ( ByteBufFlux . fromString ( Flux . just ( "Hello" ))) // Sends the request body
. responseContent () // Receives the response body
. aggregate ()
. asString ()
. log ( "http-client" )
. block ();
使用Reactor Netty
时遇到问题?我们很乐意提供帮助!
reactor-netty
标签的问题。您还可以在 Gitter 上与社区聊天。Reactor Netty
的错误。Reactor Netty
使用GitHub's
集成问题跟踪系统来记录错误和功能请求。如果您想提出问题,请遵循以下建议:
Reactor Netty
版本,以及您的Operating System
和JVM
版本。有关为Reactor Netty
做出贡献的信息,请参阅我们的贡献指南。
您不需要从源代码构建来使用Reactor Netty
(repo.spring.io 中的二进制文件),但如果您想尝试最新和最好的,可以使用 gradle 包装器轻松构建Reactor Netty
。您还需要 JDK 1.8。
$ git clone https://github.com/reactor/reactor-netty.git
$ cd reactor-netty
$ ./gradlew build
如果要将工件发布到本地Maven
存储库,请使用:
$ ./gradlew publishToMavenLocal
https://projectreactor.io/docs/netty/release/api/
Reactor Netty
是在 Apache License 2.0 下发布的开源软件