Add docs for RSocket interface client
Closes gh-24456
This commit is contained in:
@@ -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<Void>`
|
||||
| Perform the given request, and release the response content, if any.
|
||||
|
||||
@@ -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 <<rsocket-requester>>.
|
||||
|
||||
One, declare an interface with `@RSocketExchange` methods:
|
||||
|
||||
[source,java,indent=0,subs="verbatim,quotes"]
|
||||
----
|
||||
interface RadarService {
|
||||
|
||||
@RSocketExchange("radars")
|
||||
Flux<AirportLocation> 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`.
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user