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 publishToMavenLocalhttps://projectreactor.io/docs/netty/release/api/
Reactor Netty是在 Apache License 2.0 下發布的開源軟體