
يقدم Reactor Netty عملاء وخوادم TCP / HTTP / UDP / QUIC غير قابلة للحظر وجاهزة للضغط الخلفي استنادًا إلى إطار عمل Netty .
يتطلب Reactor Netty Java 8 أو + للتشغيل.
باستخدام Gradle من مستودعات repo.spring.io أو Maven Central (الإصدارات الثابتة فقط):
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 والوثائق المرجعية
إليك خادم 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 على github.com/reactor/reactor-netty/issues. يستخدم Reactor Netty نظام تتبع المشكلات المتكامل GitHub's لتسجيل الأخطاء وطلبات الميزات. إذا كنت تريد إثارة مشكلة ما، يرجى اتباع التوصيات أدناه:
Reactor Netty الذي تستخدمه، بالإضافة إلى Operating System لديك وإصدار JVM . راجع دليل المساهمة الخاص بنا للحصول على معلومات حول المساهمة في Reactor Netty .
لا تحتاج إلى البناء من المصدر لاستخدام Reactor Netty (الثنائيات في repo.spring.io)، ولكن إذا كنت ترغب في تجربة الأحدث والأفضل، فيمكن إنشاء Reactor Netty بسهولة باستخدام غلاف Gradle. تحتاج أيضًا إلى 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 2.0