Skip to content

Commit fdfa7cb

Browse files
committed
Add docs for RSocket interface client
Closes gh-24456
1 parent 8423b2c commit fdfa7cb

File tree

2 files changed

+82
-3
lines changed

2 files changed

+82
-3
lines changed

src/docs/asciidoc/integration.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -364,7 +364,7 @@ If necessary the `Content-Type` may also be set explicitly.
364364

365365

366366
[[rest-http-interface]]
367-
=== HTTP Interface
367+
=== HTTP Interface
368368

369369
The Spring Framework lets you define an HTTP service as a Java interface with annotated
370370
methods for HTTP exchanges. You can then generate a proxy that implements this interface
@@ -422,7 +422,7 @@ method parameters:
422422

423423
[cols="1,2", options="header"]
424424
|===
425-
| Controller method argument | Description
425+
| Method argument | Description
426426

427427
| `URI`
428428
| 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:
469469

470470
[cols="1,2", options="header"]
471471
|===
472-
| Controller method return value | Description
472+
| Method return value | Description
473473

474474
| `void`, `Mono<Void>`
475475
| Perform the given request, and release the response content, if any.

src/docs/asciidoc/rsocket.adoc

Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -904,3 +904,82 @@ simply use a callback to customize registrations as follows:
904904
}
905905
.build()
906906
----
907+
908+
909+
910+
911+
[[rsocket-interface]]
912+
== RSocket Interface
913+
914+
The Spring Framework lets you define an RSocket service as a Java interface with annotated
915+
methods for RSocket exchanges. You can then generate a proxy that implements this interface
916+
and performs the exchanges. This helps to simplify RSocket remote access by wrapping the
917+
use of the underlying <<rsocket-requester>>.
918+
919+
One, declare an interface with `@RSocketExchange` methods:
920+
921+
[source,java,indent=0,subs="verbatim,quotes"]
922+
----
923+
interface RadarService {
924+
925+
@RSocketExchange("radars")
926+
Flux<AirportLocation> getRadars(@Payload MapRequest request);
927+
928+
// more RSocket exchange methods...
929+
930+
}
931+
----
932+
933+
Two, create a proxy that will perform the declared RSocket exchanges:
934+
935+
[source,java,indent=0,subs="verbatim,quotes"]
936+
----
937+
RSocketRequester requester = ... ;
938+
RSocketServiceProxyFactory factory = new RSocketServiceProxyFactory(requester);
939+
factory.afterPropertiesSet();
940+
941+
RepositoryService service = factory.createClient(RadarService.class);
942+
----
943+
944+
945+
[[rsocket-interface-method-parameters]]
946+
=== Method Parameters
947+
948+
Annotated, RSocket exchange methods support flexible method signatures with the following
949+
method parameters:
950+
951+
[cols="1,2", options="header"]
952+
|===
953+
| Method argument | Description
954+
955+
| `@DestinationVariable`
956+
| Add a route variable to pass to `RSocketRequester` along with the route from the
957+
`@RSocketExchange` annotation in order to expand template placeholders in the route.
958+
This variable can be a String or any Object, which is then formatted via `toString()`.
959+
960+
| `@Payload`
961+
| Set the input payload(s) for the request. This can be a concrete value, or any producer
962+
of values that can be adapted to a Reactive Streams `Publisher` via
963+
`ReactiveAdapterRegistry`
964+
965+
| `Object`, if followed by `MimeType`
966+
| The value for a metadata entry in the input payload. This can be any `Object` as long
967+
as the next argument is the metadata entry `MimeType`. The value can be can a concrete
968+
value or any producer of a single value that can be adapted to a Reactive Streams
969+
`Publisher` via `ReactiveAdapterRegistry`.
970+
971+
| `MimeType`
972+
| The `MimeType` for a metadata entry. The preceding method argument is expected to be
973+
the metadata value.
974+
975+
|===
976+
977+
978+
[[rsocket-interface-return-values]]
979+
=== Return Values
980+
981+
Annotated, RSocket exchange methods support return values that are concrete value(s), or
982+
any producer of value(s) that can be adapted to a Reactive Streams `Publisher` via
983+
`ReactiveAdapterRegistry`.
984+
985+

0 commit comments

Comments
 (0)