Merge branch '5.2.x'
This commit is contained in:
commit
3e736898a6
|
@ -178,7 +178,7 @@ symmetrically, to make requests from clients and to make requests from servers.
|
||||||
|
|
||||||
To obtain an `RSocketRequester` on the client side requires connecting to a server along with
|
To obtain an `RSocketRequester` on the client side requires connecting to a server along with
|
||||||
preparing and sending the initial RSocket `SETUP` frame. `RSocketRequester` provides a
|
preparing and sending the initial RSocket `SETUP` frame. `RSocketRequester` provides a
|
||||||
builder for that. Internally uses RSocket Java's `RSocketFactory`.
|
builder for that. Internally it builds on `io.rsocket.core.RSocketConnector`.
|
||||||
|
|
||||||
This is the most basic way to connect with default settings:
|
This is the most basic way to connect with default settings:
|
||||||
|
|
||||||
|
@ -331,16 +331,17 @@ infrastructure that's used on a server, but registered programmatically as follo
|
||||||
.routeMatcher(new PathPatternRouteMatcher()) // <1>
|
.routeMatcher(new PathPatternRouteMatcher()) // <1>
|
||||||
.build();
|
.build();
|
||||||
|
|
||||||
ClientHandler handler = new ClientHandler(); // <2>
|
SocketAcceptor responder =
|
||||||
|
RSocketMessageHandler.responder(strategies, new ClientHandler()); // <2>
|
||||||
|
|
||||||
Mono<RSocketRequester> requesterMono = RSocketRequester.builder()
|
Mono<RSocketRequester> requesterMono = RSocketRequester.builder()
|
||||||
.rsocketFactory(RSocketMessageHandler.clientResponder(strategies, handler)) // <3>
|
.rsocketConnector(connector -> connector.acceptor(responder)) // <3>
|
||||||
.connectTcp("localhost", 7000);
|
.connectTcp("localhost", 7000);
|
||||||
----
|
----
|
||||||
<1> Use `PathPatternRouteMatcher`, if `spring-web` is present, for efficient
|
<1> Use `PathPatternRouteMatcher`, if `spring-web` is present, for efficient
|
||||||
route matching.
|
route matching.
|
||||||
<2> Create responder that contains `@MessageMaping` or `@ConnectMapping` methods.
|
<2> Create a responder from a class with `@MessageMaping` and/or `@ConnectMapping` methods.
|
||||||
<3> Use static factory method in `RSocketMessageHandler` to register one or more responders.
|
<3> Register the responder.
|
||||||
|
|
||||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||||
.Kotlin
|
.Kotlin
|
||||||
|
@ -351,16 +352,17 @@ infrastructure that's used on a server, but registered programmatically as follo
|
||||||
.routeMatcher(PathPatternRouteMatcher()) // <1>
|
.routeMatcher(PathPatternRouteMatcher()) // <1>
|
||||||
.build()
|
.build()
|
||||||
|
|
||||||
val handler = ClientHandler() // <2>
|
val responder =
|
||||||
|
RSocketMessageHandler.responder(strategies, new ClientHandler()); // <2>
|
||||||
|
|
||||||
val requester = RSocketRequester.builder()
|
val requester = RSocketRequester.builder()
|
||||||
.rsocketFactory(RSocketMessageHandler.clientResponder(strategies, handler)) // <3>
|
.rsocketConnector { it.acceptor(responder) } // <3>
|
||||||
.connectTcpAndAwait("localhost", 7000)
|
.connectTcpAndAwait("localhost", 7000)
|
||||||
----
|
----
|
||||||
<1> Use `PathPatternRouteMatcher`, if `spring-web` is present, for efficient
|
<1> Use `PathPatternRouteMatcher`, if `spring-web` is present, for efficient
|
||||||
route matching.
|
route matching.
|
||||||
<2> Create responder that contains `@MessageMaping` or `@ConnectMapping` methods.
|
<2> Create a responder from a class with `@MessageMaping` and/or `@ConnectMapping` methods.
|
||||||
<3> Use static factory method in `RSocketMessageHandler` to register one or more responders.
|
<3> Register the responder.
|
||||||
|
|
||||||
Note the above is only a shortcut designed for programmatic registration of client
|
Note the above is only a shortcut designed for programmatic registration of client
|
||||||
responders. For alternative scenarios, where client responders are in Spring configuration,
|
responders. For alternative scenarios, where client responders are in Spring configuration,
|
||||||
|
@ -373,7 +375,7 @@ you can still declare `RSocketMessageHandler` as a Spring bean and then apply as
|
||||||
RSocketMessageHandler handler = context.getBean(RSocketMessageHandler.class);
|
RSocketMessageHandler handler = context.getBean(RSocketMessageHandler.class);
|
||||||
|
|
||||||
Mono<RSocketRequester> requesterMono = RSocketRequester.builder()
|
Mono<RSocketRequester> requesterMono = RSocketRequester.builder()
|
||||||
.rsocketFactory(factory -> factory.acceptor(handler.responder()))
|
.rsocketConnector(connector -> connector.acceptor(handler.responder()))
|
||||||
.connectTcp("localhost", 7000);
|
.connectTcp("localhost", 7000);
|
||||||
----
|
----
|
||||||
|
|
||||||
|
@ -387,7 +389,7 @@ you can still declare `RSocketMessageHandler` as a Spring bean and then apply as
|
||||||
val handler = context.getBean<RSocketMessageHandler>()
|
val handler = context.getBean<RSocketMessageHandler>()
|
||||||
|
|
||||||
val requester = RSocketRequester.builder()
|
val requester = RSocketRequester.builder()
|
||||||
.rsocketFactory { it.acceptor(handler.responder()) }
|
.rsocketConnector { it.acceptor(handler.responder()) }
|
||||||
.connectTcpAndAwait("localhost", 7000)
|
.connectTcpAndAwait("localhost", 7000)
|
||||||
----
|
----
|
||||||
|
|
||||||
|
@ -404,15 +406,15 @@ See also <<rsocket-annot-responders>>, for more on the programming model.
|
||||||
==== Advanced
|
==== Advanced
|
||||||
|
|
||||||
`RSocketRequesterBuilder` provides a callback to expose the underlying
|
`RSocketRequesterBuilder` provides a callback to expose the underlying
|
||||||
`ClientRSocketFactory` from RSocket Java for further configuration options for
|
`io.rsocket.core.RSocketConnector` for further configuration options for keepalive
|
||||||
keepalive intervals, session resumption, interceptors, and more. You can configure options
|
intervals, session resumption, interceptors, and more. You can configure options
|
||||||
at that level as follows:
|
at that level as follows:
|
||||||
|
|
||||||
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
|
[source,java,indent=0,subs="verbatim,quotes",role="primary"]
|
||||||
.Java
|
.Java
|
||||||
----
|
----
|
||||||
Mono<RSocketRequester> requesterMono = RSocketRequester.builder()
|
Mono<RSocketRequester> requesterMono = RSocketRequester.builder()
|
||||||
.rsocketFactory(factory -> {
|
.rsocketConnector(connector -> {
|
||||||
// ...
|
// ...
|
||||||
})
|
})
|
||||||
.connectTcp("localhost", 7000);
|
.connectTcp("localhost", 7000);
|
||||||
|
@ -424,7 +426,7 @@ at that level as follows:
|
||||||
import org.springframework.messaging.rsocket.connectTcpAndAwait
|
import org.springframework.messaging.rsocket.connectTcpAndAwait
|
||||||
|
|
||||||
val requester = RSocketRequester.builder()
|
val requester = RSocketRequester.builder()
|
||||||
.rsocketFactory {
|
.rsocketConnector {
|
||||||
//...
|
//...
|
||||||
}.connectTcpAndAwait("localhost", 7000)
|
}.connectTcpAndAwait("localhost", 7000)
|
||||||
----
|
----
|
||||||
|
@ -636,10 +638,8 @@ Then start an RSocket server through the Java RSocket API and plug the
|
||||||
RSocketMessageHandler handler = context.getBean(RSocketMessageHandler.class);
|
RSocketMessageHandler handler = context.getBean(RSocketMessageHandler.class);
|
||||||
|
|
||||||
CloseableChannel server =
|
CloseableChannel server =
|
||||||
RSocketFactory.receive()
|
RSocketServer.create(handler.responder())
|
||||||
.acceptor(handler.responder())
|
.bind(TcpServerTransport.create("localhost", 7000))
|
||||||
.transport(TcpServerTransport.create("localhost", 7000))
|
|
||||||
.start()
|
|
||||||
.block();
|
.block();
|
||||||
----
|
----
|
||||||
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
[source,kotlin,indent=0,subs="verbatim,quotes",role="secondary"]
|
||||||
|
@ -650,10 +650,9 @@ Then start an RSocket server through the Java RSocket API and plug the
|
||||||
val context: ApplicationContext = ...
|
val context: ApplicationContext = ...
|
||||||
val handler = context.getBean<RSocketMessageHandler>()
|
val handler = context.getBean<RSocketMessageHandler>()
|
||||||
|
|
||||||
val server = RSocketFactory.receive()
|
val server = RSocketServer.create(handler.responder())
|
||||||
.acceptor(handler.responder())
|
.bind(TcpServerTransport.create("localhost", 7000))
|
||||||
.transport(TcpServerTransport.create("localhost", 7000))
|
.awaitFirst()
|
||||||
.start().awaitFirst()
|
|
||||||
----
|
----
|
||||||
|
|
||||||
`RSocketMessageHandler` supports
|
`RSocketMessageHandler` supports
|
||||||
|
|
Loading…
Reference in New Issue