Skip to content

Commit b210d2f

Browse files
committed
Merge pull request #18321 from rstoyanchev
* gh-18321: Polish "Reference Spring Framework RSocket section + polish" Reference Spring Framework RSocket section + polish Closes gh-18321
2 parents b9cfbf7 + 60b1bbb commit b210d2f

File tree

1 file changed

+13
-39
lines changed

1 file changed

+13
-39
lines changed

spring-boot-project/spring-boot-docs/src/main/asciidoc/spring-boot-features.adoc

Lines changed: 13 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -2930,31 +2930,9 @@ You can learn more about the resource configuration on the client side in the <<
29302930
https://rsocket.io[RSocket] is a binary protocol for use on byte stream transports.
29312931
It enables symmetric interaction models via async message passing over a single connection.
29322932

2933-
Spring Framework, with the Spring Messaging module supports RSocket both on the server and the client side.
2934-
On the server side, it lets you create special `@Controller` beans to handle incoming RSocket messages.
2935-
Methods in your controller are mapped to RSocket routes by using `@MessageMapping` annotations.
2936-
2937-
The following code shows a typical `@Controller`:
2938-
2939-
[source,java,indent=0]
2940-
----
2941-
@Controller
2942-
public class MyRSocketController {
2943-
2944-
@MessageMapping("chat.room.{name}")
2945-
public Flux<ChatMessages> enterChatRoom(@DestinationVariable String chatRoom,
2946-
Flux<ChatMessages> messages) {
2947-
// ...
2948-
}
2949-
2950-
@MessageMapping("users.\{user}.info")
2951-
Mono<ChatUserInfo> getUserInfo(@DestinationVariable String user) {
2952-
// ...
2953-
}
2954-
2955-
}
2956-
----
29572933

2934+
The `spring-messaging` module of the Spring Framework provides support for RSocket requesters and responders, both on the client and on the server side.
2935+
See the {spring-framework-docs}web-reactive.html#rsocket-spring[RSocket section] of the Spring Framework reference for more details, including an overview of the RSocket protocol.
29582936

29592937

29602938
[[boot-features-rsocket-strategies-auto-configuration]]
@@ -2966,21 +2944,21 @@ By default, the auto-configuration will try to configure the following (in order
29662944
. JSON codecs with Jackson
29672945

29682946
The `spring-boot-starter-rsocket` starter provides both dependencies.
2947+
Check out the <<boot-features-json-jackson,Jackson support section>> to know more about customization possibilities.
29692948

29702949
Developers can customize the `RSocketStrategies` component by creating beans that implement the `RSocketStrategiesCustomizer` interface.
29712950
Note that their `@Order` is important, as it determines the order of codecs.
29722951

29732952

2974-
29752953
[[boot-features-rsocket-server-auto-configuration]]
29762954
=== RSocket server Auto-configuration
2977-
Spring Boot provides auto-configuration for RSocket servers.
2955+
Spring Boot provides RSocket server auto-configuration.
29782956
The required dependencies are provided by the `spring-boot-starter-rsocket`.
29792957

2980-
Spring Boot will start an RSocket server as a new embedded server in your application, or will plug the RSocket infrastructure into an existing reactive Web server.
2958+
Spring Boot allows exposing RSocket over WebSocket from a WebFlux server, or standing up an independent RSocket server.
29812959
This depends on the type of application and its configuration.
29822960

2983-
In case of a WebFlux application (i.e. of type `WebApplicationType.REACTIVE`), the RSocket server will be plugged into the existing Web Server only if the following properties match:
2961+
For WebFlux application (i.e. of type `WebApplicationType.REACTIVE`), the RSocket server will be plugged into the Web Server only if the following properties match:
29842962

29852963
[source,properties,indent=0,subs="verbatim,quotes,attributes"]
29862964
----
@@ -2989,9 +2967,9 @@ In case of a WebFlux application (i.e. of type `WebApplicationType.REACTIVE`), t
29892967
#spring.rsocket.server.port= # no port is defined
29902968
----
29912969

2992-
WARNING: Plugging RSocket into an existing web server is only supported with Reactor Netty, as RSocket itself is built with that library.
2970+
WARNING: Plugging RSocket into a web server is only supported with Reactor Netty, as RSocket itself is built with that library.
29932971

2994-
The only other way to create an RSocket server is to start an independent, embedded RSocket server.
2972+
Alternatively, an RSocket TCP or websocket server is started as an independent, embedded server.
29952973
Besides the dependency requirements, the only required configuration is to define a port for that server:
29962974

29972975
[source,properties,indent=0,subs="verbatim,quotes,attributes"]
@@ -3006,23 +2984,19 @@ Besides the dependency requirements, the only required configuration is to defin
30062984
=== Spring Messaging RSocket support
30072985
Spring Boot will auto-configure the Spring Messaging infrastructure for RSocket.
30082986

3009-
An `RSocketStrategies` bean is created to provide encoding and decoding support for RSocket messages.
3010-
By default, Spring Boot will try to auto-configure JSON support with Jackson for `application/json` and `"application/*+json"` media types.
3011-
Check out the <<boot-features-json-jackson,Jackson support section>> to know more about customization possibilities.
3012-
3013-
Developers can create `RSocketStrategiesCustomizer` beans to add other strategies, assuming there are `Encoder` and `Decoder` implementations available.
3014-
2987+
This means that Spring Boot will create a `RSocketMessageHandler` bean that will handle RSocket requests to your application.
30152988

30162989

30172990
[[boot-features-rsocket-requester]]
30182991
=== Calling RSocket Services with `RSocketRequester`
30192992
Once the `RSocket` channel is established between server and client, any party can send or receive requests to the other.
30202993

3021-
As a server, you can get injected an `RSocketRequester` instance on any handler method of an RSocket `@Controller`.
2994+
As a server, you can get injected with an `RSocketRequester` instance on any handler method of an RSocket `@Controller`.
30222995
As a client, you need to configure and establish an RSocket connection first.
30232996
Spring Boot auto-configures an `RSocketRequester.Builder` for such cases with the expected codecs.
30242997

3025-
The `RSocketRequester.Builder` instance is a prototype bean, meaning each injection point will provide you with a new instance - this is done on purpose since this builder is stateful and you shouldn't create requesters with different setups using the same instance.
2998+
The `RSocketRequester.Builder` instance is a prototype bean, meaning each injection point will provide you with a new instance .
2999+
This is done on purpose since this builder is stateful and you shouldn't create requesters with different setups using the same instance.
30263000

30273001
The following code shows a typical example:
30283002

@@ -3035,7 +3009,7 @@ The following code shows a typical example:
30353009
30363010
public MyService(RSocketRequester.Builder rsocketRequesterBuilder) {
30373011
this.rsocketRequester = rsocketRequesterBuilder
3038-
.connectTcp("example.org", 9090).block();
3012+
.connectTcp("example.org", 9898).block();
30393013
}
30403014
30413015
public Mono<User> someRSocketCall(String name) {

0 commit comments

Comments
 (0)