From fdfa7cbae633a4220003c3edfd1541f5a1531e2b Mon Sep 17 00:00:00 2001 From: rstoyanchev Date: Wed, 7 Sep 2022 14:37:34 +0100 Subject: [PATCH] Add docs for RSocket interface client Closes gh-24456 --- src/docs/asciidoc/integration.adoc | 6 +-- src/docs/asciidoc/rsocket.adoc | 79 ++++++++++++++++++++++++++++++ 2 files changed, 82 insertions(+), 3 deletions(-) diff --git a/src/docs/asciidoc/integration.adoc b/src/docs/asciidoc/integration.adoc index b8f0da9eb1..866fc8f149 100644 --- a/src/docs/asciidoc/integration.adoc +++ b/src/docs/asciidoc/integration.adoc @@ -364,7 +364,7 @@ If necessary the `Content-Type` may also be set explicitly. [[rest-http-interface]] -=== HTTP Interface + === HTTP Interface The Spring Framework lets you define an HTTP service as a Java interface with annotated methods for HTTP exchanges. You can then generate a proxy that implements this interface @@ -422,7 +422,7 @@ method parameters: [cols="1,2", options="header"] |=== -| Controller method argument | Description +| Method argument | Description | `URI` | Dynamically set the URL for the request, overriding the annotation's `url` attribute. @@ -469,7 +469,7 @@ Annotated, HTTP exchange methods support the following return values: [cols="1,2", options="header"] |=== -| Controller method return value | Description +| Method return value | Description | `void`, `Mono` | Perform the given request, and release the response content, if any. diff --git a/src/docs/asciidoc/rsocket.adoc b/src/docs/asciidoc/rsocket.adoc index e0c9c42ade..25ead33294 100644 --- a/src/docs/asciidoc/rsocket.adoc +++ b/src/docs/asciidoc/rsocket.adoc @@ -904,3 +904,82 @@ simply use a callback to customize registrations as follows: } .build() ---- + + + + +[[rsocket-interface]] +== RSocket Interface + +The Spring Framework lets you define an RSocket service as a Java interface with annotated +methods for RSocket exchanges. You can then generate a proxy that implements this interface +and performs the exchanges. This helps to simplify RSocket remote access by wrapping the +use of the underlying <>. + +One, declare an interface with `@RSocketExchange` methods: + +[source,java,indent=0,subs="verbatim,quotes"] +---- + interface RadarService { + + @RSocketExchange("radars") + Flux getRadars(@Payload MapRequest request); + + // more RSocket exchange methods... + + } +---- + +Two, create a proxy that will perform the declared RSocket exchanges: + +[source,java,indent=0,subs="verbatim,quotes"] +---- + RSocketRequester requester = ... ; + RSocketServiceProxyFactory factory = new RSocketServiceProxyFactory(requester); + factory.afterPropertiesSet(); + + RepositoryService service = factory.createClient(RadarService.class); +---- + + +[[rsocket-interface-method-parameters]] +=== Method Parameters + +Annotated, RSocket exchange methods support flexible method signatures with the following +method parameters: + +[cols="1,2", options="header"] +|=== +| Method argument | Description + +| `@DestinationVariable` +| Add a route variable to pass to `RSocketRequester` along with the route from the + `@RSocketExchange` annotation in order to expand template placeholders in the route. + This variable can be a String or any Object, which is then formatted via `toString()`. + +| `@Payload` +| Set the input payload(s) for the request. This can be a concrete value, or any producer + of values that can be adapted to a Reactive Streams `Publisher` via + `ReactiveAdapterRegistry` + +| `Object`, if followed by `MimeType` +| The value for a metadata entry in the input payload. This can be any `Object` as long + as the next argument is the metadata entry `MimeType`. The value can be can a concrete + value or any producer of a single value that can be adapted to a Reactive Streams + `Publisher` via `ReactiveAdapterRegistry`. + +| `MimeType` +| The `MimeType` for a metadata entry. The preceding method argument is expected to be + the metadata value. + +|=== + + +[[rsocket-interface-return-values]] +=== Return Values + +Annotated, RSocket exchange methods support return values that are concrete value(s), or +any producer of value(s) that can be adapted to a Reactive Streams `Publisher` via +`ReactiveAdapterRegistry`. + +