@@ -904,3 +904,82 @@ simply use a callback to customize registrations as follows:
904
904
}
905
905
.build()
906
906
----
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