1. Learning RSocket
Using RSC
September 1–2, 2021
springone.io
Toshiaki Maki (@making)
Staff Cloud Native Architect at VMware
https://github.com/making/learning-rsocket-using-rsc
1
2. What is RSocket?
● RSocket is a binary protocol for multiplexed, bidirectional over TCP or
WebSocket
○ https://rsocket.io
○ Layer 5 or 6 in the OSI model / Application layer in the TCP/IP model
● 4 interaction models
○ Request Response
○ Request Stream
○ Request Channel
○ Fire and Forget
● Support Reactive Streams semantics (Backpressure)
● A Reactive Foundation project
○ https://www.reactive.foundation
2
3. FAQ: What’s different from gRPC?
3
Transport Agnostic
(TCP / WebSocket / …)
RSocket Protocol
Message Format Agnostic
(JSON / CBOR / Protocol Buffers / ...)
Programming Model Agnostic
(Messaging / RPC / Functional Style)
Language Agnostic
(Java / Kotlin / JavaScript / Swift / ...)
HTTP/2
Protocol Buffers
RPC Style
Language Agnostic
(Go / C++ / Java / Python / C# / ...)
Transport
Message
Format
Programming
Model
Language
4. Spring ❤ RSocket
Spring Framework provides a “Messaging Style” and “Functional Style”
programming model for RSocket
And a convenient RSocket Client like WebClient for Spring WebFlux
https://docs.spring.io/spring-framework/docs/current/reference/html/web-reactive.html#rsocket
4
@Controller
public class UpperCase {
@MessageMapping("uc")
String uc(@Payload String s) {
return s.toUpperCase();
}
}
RSocketRequester requester =
RSocketRequester.builder()
.tcp("localhost", 7000);
Mono<String> response =
requester.route("uc")
.data("Hello")
.retrieveMono(String.class);
Server Client
5. What is RSC?
RSC is a CLI for RSocket like curl for HTTP.
https://github.com/making/rsc
Uses RSocket Java SDK and built with GraalVM into a native image.
Available for Mac, Linux and Windows.
Very convenient for testing RSocket Server API.
5
$ brew install making/tap/rsc
$ rsc --route=uc --data=Hello tcp://localhost:7000
HELLO
6. 4 Interaction Models
● Request Response … send one message and receive one back
● Request Stream … send one message and receive a stream of messages
● Request Channel … send streams of messages in both directions
● Fire and Forget … send a one-way message
6
28. Wrap up
● RSocket is a binary protocol for multiplexed, bidirectional over TCP or WebSocket
● Spring ❤ RSocket
● RSC is a CLI for RSocket like curl for HTTP.
● 4 interaction models
○ Request Response
○ Request Stream
○ Request Channel
○ Fire and Forget
● Highlighted features
○ Backpressure
○ Session Resumption
○ Client Responder
○ Authentication
○ Tracing
2
8
29. https://github.com/making/learning-rsocket-using-rsc
Event Sourcing with RSocket—Now We’re Talking! - Steven van Beelen
Collaborative Applications at Scale with RSocket - Sergey Tselovalnikov
Multiplatform Apps with Spring, Kotlin, and RSocket - Anton Arhipov, Oleh Dokuka
#springone
@SpringOne
Stay Connected.