SlideShare une entreprise Scribd logo
1  sur  66
Télécharger pour lire hors ligne
Multi-Service Reactive Streams using
RSocket, Reactor, and Spring
Ben Hale, Cloud Foundry Java Experience Lead
@nebhale
Stephane Maldini, Project Reactor Lead
@smaldini
Reactive Programming
• Reactive programming is the next frontier in Java for high-efficiency
applications
• Fundamentally non-blocking and often paired with asynchronous
behaviors
• Reactive has no opinion on async and many flows are totally
synchronous
• Key differentiator from "async" is Reactive (pull-push) back pressure
WebFlux and WebClient
@GetMapping("/health")
Mono<Health> compositeHealth() {
return Mono.zip(
webClient.get().uri("https://alpha-service/health")
.retrieve().bodyToMono(Health.class),
webClient.get().uri("https://bravo-service/health")
.retrieve().bodyToMono(Health.class))
.map(t -> composite(t.getT1(), t.getT2()));
}
Roadblocks
• But there are still some barriers to using Reactive everywhere*
• Data Access
• MongoDB, Apache Cassandra, and Redis
• No relational database access
• Cross-process back pressure (networking)
Roadblocks
• But there are still some barriers to using Reactive everywhere*
• Data Access
• MongoDB, Apache Cassandra, and Redis
• No relational database access
• Cross-process back pressure (networking)
Until R2DBC ! Check out r2dbc.io
• No relational database access
http://rsocket.io
Message Driven Binary Protocol
• Requester-Responder interaction is broken down into frames that
encapsulate messages
• The framing is binary (not human readable like JSON or XML)
• Massive efficiencies for machine-to-machine communication
• Downsides only manifest rarely and can be mitigated with tooling
• Payloads are bags of bytes
• Can be JSON or XML (it's all just 1's and 0's)
request/reply
request/void (fire&forget)
request/stream
stream/stream (channel)
4 defined interaction models
request/replyrequest/reply
request/reply request/reply
request/reply request/replyrequest/reply
request/reply request/replyrequest/reply
request/reply request/replyrequest/reply
🔎multiplexed
🔎transport agnostic 

e.g. Websocket
request/streamrequest/stream
request/streamrequest/stream
request/stream
🔎 🔎
bidirectional
Bi-Directional
• Many protocols (notably not TCP) have a distinction between the client
and server for the lifetime of a connection
• This division means that one side of the connection must initiate all
requests, and the other side must initiate all responses
• Even more flexible protocols like HTTP/2 do not fully drop the distinction
• Servers cannot start an unrequested stream of data to the client
• Once a client initiates a connection to a server, both parties can be
requestors or responders to a logical stream
2
per-message

flow-control
2 2
per-message

flow-control
2
per-message

flow-control
00
per-message

flow-control
0
per-message

flow-control
Reactive Streams Back Pressure
• Network protocols generally send a single request, and receive an
arbitrarily large response in return
• There is nothing to stop the responder (or even the requestor) from
sending an arbitrarily large amount of data and overwhelming the
receiver
• In cases where TCP back pressure throttles the responder, queues fill
with large amounts of un-transferred data
• Reactive Streams (pull-push) back pressure ensures that data is only
materialized and transferred when receiver is ready to process it
20 0
302 0
21
3 2
2
2
3 22
23 2
3
3 2
3
❌
3 22
3 2
Resumption
22
3 23
3
Resumption
3 33
3
Resumption
Resumption/Resumability
• Starting as a client-to-edge-server protocol highlighted a common failing of
existing options
• Clients on unstable connections would often drop and need to re-establish
current state
• Led to inefficiencies in both network traffic and data-center compute
• Resumability allows both parties in a "logical connection" to identify
themselves on reconnection
• On Resumption both parties handshake about the last frame received and all
missed frames are re-transmitted
• Frame caching to support is not defined by spec so it can be very flexible
36
language agnostic
compose with no semantics loss
🔎
🔎
🔎
ws
tcp
udp
RSocket Protocol
TCP WebSocket Aeron/UDPHTTP/2
Protobuf JSON Custom Binary
RPC-style Messaging
Java JavaScript C++ Kotlin Flow
Using the RSocket API
Java API
public interface RSocket {
Mono<Payload> requestResponse(Payload payload);
Mono<Void> fireAndForget(Payload payload);
Flux<Payload> requestStream(Payload payload);
Flux<Payload> requestChannel(Flux<Payload> payloads);
}
Java API
public interface RSocket {
Mono<Payload> requestResponse(Payload payload);
Mono<Void> fireAndForget(Payload payload);
Flux<Payload> requestStream(Payload payload);
Flux<Payload> requestChannel(Flux<Payload> payloads);
}
Interaction Models – Request-Response
Mono<Payload> resp = client.requestResponse(requestPayload)
• Standard Request-Response semantics
• Likely to represent the majority of requests for the foreseeable future
• Even this obvious interaction model surpasses HTTP because it is
asynchronous and multiplexed
• Request with account number, respond with account balance
Interaction Models – Fire-and-Forget
Mono<Void> resp = client.fireAndForget(requestPayload)
• An optimization of Request-Response when a response isn't necessary
• Significant efficiencies
• Networking (no ack)
• Client/Server processing (immediate release of resources)
• Non-critical event logging
Interaction Models – Request-Stream
Flux<Payload> resp = client.requestStream(requestPayload)
• Analogous to Request-Response returning a collection
• The collection is streamed back instead of queuing until complete
• RequestN semantics mean data is not materialized until ready to send
• Request with account number, respond with real-time stream of account
transactions
Interaction Models – Channel
Flux<Payload> out = client.requestChannel(Flux<Payload> in)
• A bi-directional stream of messages in both directions
• An unstructured channel allows arbitrary interaction models
• Request burst of initial state, listen for subsequent updates, client
updates subscription without starting new connection
• Request with account number, respond with real-time stream of account
transactions, update subscription to filter certain transaction types,
respond with filtered real-time stream of account transactions
Raw Client
RSocket client =
RSocketFactory.connect()
.transport(TcpClientTransport.create("1.2.3.4", 80))
.start()
.block();
Raw Client
RSocket client =
RSocketFactory.connect()
.transport(TcpClientTransport.create("1.2.3.4", 80))
.start()
.block();
client.requestResponse(new DefaultPayload(…))
.doOnComplete(() -> System.out.println(“hooray”)
.subscribe();
Raw Client
RSocket client =
RSocketFactory.connect()
.transport(TcpClientTransport.create("1.2.3.4", 80))
.start()
.block();
client.requestResponse(new DefaultPayload(…))
.doOnComplete(() -> System.out.println(“hooray”)
.subscribe();
Censored ByteBuffer creation
Raw Client
Too Low Level ?

Shift to the next gear with existing tech built on RSocket
😱
Building applications with RSocket API
• Programming Model Agnostic
• The RSocket interface is a serviceable programming model but not
great
• Designed to be a building block that multiple other programming models
could build upon
Building applications with RSocket API
• Making things simpler:
• RPC-style (protobuf code generation)
• Messaging-style (Spring message handlers/controllers)
RPC-style (Contract Driven)
service RecordsService {
rpc records (RecordsRequest) returns (stream Record) {}
}
RPC-style (Contract Driven)
service RecordsService {
rpc records (RecordsRequest) returns (stream Record) {}
}
RecordsServiceClient rankingService =
new RecordsServiceClient(rsocket);
recordsService.records(RecordsRequest.newBuilder()
.setMaxResults(16)
.build())
.subscribe(record -> System.out.println(record));
RPC-style (Contract Driven)
service RecordsService {
rpc records (RecordsRequest) returns (stream Record) {}
}
RecordsServiceClient rankingService =
new RecordsServiceClient(rsocket);
recordsService.records(RecordsRequest.newBuilder()
.setMaxResults(16)
.build())
.subscribe(record -> System.out.println(record));
You still need to manage this part
RPC-style (Contract Driven)
service RecordsService {
rpc records (RecordsRequest) returns (stream Record) {}
}
RPC-style (Contract Driven)
service RecordsService {
rpc records (RecordsRequest) returns (stream Record) {}
}
let recordServiceClient = new RecordsServiceClient(rsocket);
let req = new RecordRequest();
req.setMaxResults(16);
recordServiceClient.records(req)
.subscribe();
Messaging-Style
static class TestHandler implements RSocketHandler {
@MessageMapping("/canonical")
Mono<String> handleCanonical(String payload) {
return Mono.delay(Duration.ofMillis(10))
.map(l -> createResponse(payload));
}
@MessageMapping("/async-arg")
Mono<String> handleMonoArg(Mono<String> payload) {
return payload.map(ServerResponderApp::createResponse);
}
}
Additional Protocol Features
Metadata and Data in Frames
• Each Frame has an optional metadata payload
• The metadata payload has a MIME-Type but is otherwise unstructured
• Very flexible
• Can be used to carry metadata about the data payload
• Can be used to carry metadata in order to decode the payload
• Generally means that payloads can be heterogenous and each message
decoded uniquely
Fragmentation
• Payload frames have no maximum size
• The protocol is well suited to serving large payloads
• Still Images (Facebook), Video (Netflix)
• Both TCP MTUs and reliability on slow connections lead towards smaller
payloads
• Fragmentation provides a way to continue to reason about "logical
frames" while ensuring that individual payloads are smaller
• Applied transparently, after enforcement of RequestN semantics
Cancellation
• All interaction types support cancellation
• Cancellation is a signal by the requestor that any inflight processing
should be terminated eagerly and aggressively
• An obvious requirement for Request-Stream and Channel
• But useful even in Request-Response where the response can be
expensive to generate
• Early termination can lead to significant improvement in efficiency
Leasing
• Reactive back pressure ensures that a responder (or either party in a
Channel) cannot overwhelm the receiver
• This does not prevent a requestor from overwhelming a responder
• This commonly happens in server-to-server environments where
throughput is high
• Leasing enables responders to signal capacity to requestors
• This signal is useful for client-side load-balancing
• Without preventing server-side load-balancing
RSocket
• RSocket is a bi-directional, multiplexed, message-based, binary protocol
• Utilizes Reactive Streams back pressure for efficiency and predictability
• Provides primitives for the four common interaction models
• Flexibility in transport, payload, language, and programming model
• Let us know which programming model you prefer!
• Myriad other features that make it great for modern application-to-
application communication
> Stay Connected.
https://projectreactor.io

http://rsocket.io

Contenu connexe

Tendances

HTTP/2 Comes to Java - What Servlet 4.0 Means to You
HTTP/2 Comes to Java - What Servlet 4.0 Means to YouHTTP/2 Comes to Java - What Servlet 4.0 Means to You
HTTP/2 Comes to Java - What Servlet 4.0 Means to YouDavid Delabassee
 
Reactive Java: Promises and Streams with Reakt (JavaOne talk 2016)
Reactive Java: Promises and Streams with Reakt  (JavaOne talk 2016)Reactive Java: Promises and Streams with Reakt  (JavaOne talk 2016)
Reactive Java: Promises and Streams with Reakt (JavaOne talk 2016)Rick Hightower
 
HTTP2:新的机遇与挑战
HTTP2:新的机遇与挑战HTTP2:新的机遇与挑战
HTTP2:新的机遇与挑战Jerry Qu
 
Introducing HTTP/2
Introducing HTTP/2Introducing HTTP/2
Introducing HTTP/2Ido Flatow
 
HTTP/2 Introduction
HTTP/2 IntroductionHTTP/2 Introduction
HTTP/2 IntroductionWalter Liu
 
HTTP/2: What no one is telling you
HTTP/2: What no one is telling youHTTP/2: What no one is telling you
HTTP/2: What no one is telling youFastly
 
Messaging for Web and Mobile with Apache ActiveMQ
Messaging for Web and Mobile with Apache ActiveMQMessaging for Web and Mobile with Apache ActiveMQ
Messaging for Web and Mobile with Apache ActiveMQdejanb
 
Java EE 8: What Servlet 4.0 and HTTP/2 mean to you
Java EE 8: What Servlet 4.0 and HTTP/2 mean to youJava EE 8: What Servlet 4.0 and HTTP/2 mean to you
Java EE 8: What Servlet 4.0 and HTTP/2 mean to youAlex Theedom
 
A SPDYier Experience by Olaniyi Jinadu
A SPDYier Experience by Olaniyi JinaduA SPDYier Experience by Olaniyi Jinadu
A SPDYier Experience by Olaniyi JinaduOlaniyi Jinadu
 
Introduction to HTTP/2
Introduction to HTTP/2Introduction to HTTP/2
Introduction to HTTP/2Ido Flatow
 
Using OVSDB and OpenFlow southbound plugins
Using OVSDB and OpenFlow southbound pluginsUsing OVSDB and OpenFlow southbound plugins
Using OVSDB and OpenFlow southbound pluginsOpenDaylight
 
HTTP/2 standard for video streaming
HTTP/2 standard for video streamingHTTP/2 standard for video streaming
HTTP/2 standard for video streamingHung Thai Le
 
Grokking TechTalk #24: Kafka's principles and protocols
Grokking TechTalk #24: Kafka's principles and protocolsGrokking TechTalk #24: Kafka's principles and protocols
Grokking TechTalk #24: Kafka's principles and protocolsGrokking VN
 
HTTP2 & HPACK #pyfes 2013-11-30
HTTP2 & HPACK #pyfes 2013-11-30HTTP2 & HPACK #pyfes 2013-11-30
HTTP2 & HPACK #pyfes 2013-11-30Jxck Jxck
 
HTTP 2.0 – What do I need to know?
HTTP 2.0 – What do I need to know? HTTP 2.0 – What do I need to know?
HTTP 2.0 – What do I need to know? Sigma Software
 
Introduction to HTTP/2
Introduction to HTTP/2Introduction to HTTP/2
Introduction to HTTP/2Ido Flatow
 
HTTP/2 for Developers
HTTP/2 for DevelopersHTTP/2 for Developers
HTTP/2 for DevelopersSvetlin Nakov
 
Java EE 8: What Servlet 4 and HTTP2 Mean
Java EE 8: What Servlet 4 and HTTP2 MeanJava EE 8: What Servlet 4 and HTTP2 Mean
Java EE 8: What Servlet 4 and HTTP2 MeanAlex Theedom
 
HTTP/2 What's inside and Why
HTTP/2 What's inside and WhyHTTP/2 What's inside and Why
HTTP/2 What's inside and WhyAdrian Cole
 

Tendances (20)

HTTP/2 Comes to Java - What Servlet 4.0 Means to You
HTTP/2 Comes to Java - What Servlet 4.0 Means to YouHTTP/2 Comes to Java - What Servlet 4.0 Means to You
HTTP/2 Comes to Java - What Servlet 4.0 Means to You
 
Reactive Java: Promises and Streams with Reakt (JavaOne talk 2016)
Reactive Java: Promises and Streams with Reakt  (JavaOne talk 2016)Reactive Java: Promises and Streams with Reakt  (JavaOne talk 2016)
Reactive Java: Promises and Streams with Reakt (JavaOne talk 2016)
 
HTTP2:新的机遇与挑战
HTTP2:新的机遇与挑战HTTP2:新的机遇与挑战
HTTP2:新的机遇与挑战
 
Introducing HTTP/2
Introducing HTTP/2Introducing HTTP/2
Introducing HTTP/2
 
HTTP/2 Introduction
HTTP/2 IntroductionHTTP/2 Introduction
HTTP/2 Introduction
 
HTTP/2: What no one is telling you
HTTP/2: What no one is telling youHTTP/2: What no one is telling you
HTTP/2: What no one is telling you
 
Messaging for Web and Mobile with Apache ActiveMQ
Messaging for Web and Mobile with Apache ActiveMQMessaging for Web and Mobile with Apache ActiveMQ
Messaging for Web and Mobile with Apache ActiveMQ
 
Java EE 8: What Servlet 4.0 and HTTP/2 mean to you
Java EE 8: What Servlet 4.0 and HTTP/2 mean to youJava EE 8: What Servlet 4.0 and HTTP/2 mean to you
Java EE 8: What Servlet 4.0 and HTTP/2 mean to you
 
A SPDYier Experience by Olaniyi Jinadu
A SPDYier Experience by Olaniyi JinaduA SPDYier Experience by Olaniyi Jinadu
A SPDYier Experience by Olaniyi Jinadu
 
Introduction to HTTP/2
Introduction to HTTP/2Introduction to HTTP/2
Introduction to HTTP/2
 
Using OVSDB and OpenFlow southbound plugins
Using OVSDB and OpenFlow southbound pluginsUsing OVSDB and OpenFlow southbound plugins
Using OVSDB and OpenFlow southbound plugins
 
Grpc present
Grpc presentGrpc present
Grpc present
 
HTTP/2 standard for video streaming
HTTP/2 standard for video streamingHTTP/2 standard for video streaming
HTTP/2 standard for video streaming
 
Grokking TechTalk #24: Kafka's principles and protocols
Grokking TechTalk #24: Kafka's principles and protocolsGrokking TechTalk #24: Kafka's principles and protocols
Grokking TechTalk #24: Kafka's principles and protocols
 
HTTP2 & HPACK #pyfes 2013-11-30
HTTP2 & HPACK #pyfes 2013-11-30HTTP2 & HPACK #pyfes 2013-11-30
HTTP2 & HPACK #pyfes 2013-11-30
 
HTTP 2.0 – What do I need to know?
HTTP 2.0 – What do I need to know? HTTP 2.0 – What do I need to know?
HTTP 2.0 – What do I need to know?
 
Introduction to HTTP/2
Introduction to HTTP/2Introduction to HTTP/2
Introduction to HTTP/2
 
HTTP/2 for Developers
HTTP/2 for DevelopersHTTP/2 for Developers
HTTP/2 for Developers
 
Java EE 8: What Servlet 4 and HTTP2 Mean
Java EE 8: What Servlet 4 and HTTP2 MeanJava EE 8: What Servlet 4 and HTTP2 Mean
Java EE 8: What Servlet 4 and HTTP2 Mean
 
HTTP/2 What's inside and Why
HTTP/2 What's inside and WhyHTTP/2 What's inside and Why
HTTP/2 What's inside and Why
 

Similaire à Multi-service reactive streams using Spring, Reactor, RSocket

Reactive Programming in Java and Spring Framework 5
Reactive Programming in Java and Spring Framework 5Reactive Programming in Java and Spring Framework 5
Reactive Programming in Java and Spring Framework 5Richard Langlois P. Eng.
 
HBaseCon2017 Highly-Available HBase
HBaseCon2017 Highly-Available HBaseHBaseCon2017 Highly-Available HBase
HBaseCon2017 Highly-Available HBaseHBaseCon
 
Reactive Streams 1.0.0 and Why You Should Care (webinar)
Reactive Streams 1.0.0 and Why You Should Care (webinar)Reactive Streams 1.0.0 and Why You Should Care (webinar)
Reactive Streams 1.0.0 and Why You Should Care (webinar)Legacy Typesafe (now Lightbend)
 
Reactive solutions using java 9 and spring reactor
Reactive solutions using java 9 and spring reactorReactive solutions using java 9 and spring reactor
Reactive solutions using java 9 and spring reactorOrenEzer1
 
Flexible and Real-Time Stream Processing with Apache Flink
Flexible and Real-Time Stream Processing with Apache FlinkFlexible and Real-Time Stream Processing with Apache Flink
Flexible and Real-Time Stream Processing with Apache FlinkDataWorks Summit
 
Architectural Patterns - Interactive and Event Handling Patterns
Architectural Patterns  - Interactive and Event Handling PatternsArchitectural Patterns  - Interactive and Event Handling Patterns
Architectural Patterns - Interactive and Event Handling Patternsassinha
 
Guide to Spring Reactive Programming using WebFlux
Guide to Spring Reactive Programming using WebFluxGuide to Spring Reactive Programming using WebFlux
Guide to Spring Reactive Programming using WebFluxInexture Solutions
 
Server system architecture
Server system architectureServer system architecture
Server system architectureFaiza Hafeez
 
Journey into Reactive Streams and Akka Streams
Journey into Reactive Streams and Akka StreamsJourney into Reactive Streams and Akka Streams
Journey into Reactive Streams and Akka StreamsKevin Webber
 
SenchaCon 2016: How to Give your Sencha App Real-time Web Performance - James...
SenchaCon 2016: How to Give your Sencha App Real-time Web Performance - James...SenchaCon 2016: How to Give your Sencha App Real-time Web Performance - James...
SenchaCon 2016: How to Give your Sencha App Real-time Web Performance - James...Sencha
 
CHP-4.pptx
CHP-4.pptxCHP-4.pptx
CHP-4.pptxFamiDan
 
5 application serversforproject
5 application serversforproject5 application serversforproject
5 application serversforprojectashish61_scs
 
Kafka summit SF 2019 - the art of the event-streaming app
Kafka summit SF 2019 - the art of the event-streaming appKafka summit SF 2019 - the art of the event-streaming app
Kafka summit SF 2019 - the art of the event-streaming appNeil Avery
 
The art of the event streaming application: streams, stream processors and sc...
The art of the event streaming application: streams, stream processors and sc...The art of the event streaming application: streams, stream processors and sc...
The art of the event streaming application: streams, stream processors and sc...confluent
 
Mario Fusco - Reactive programming in Java - Codemotion Milan 2017
Mario Fusco - Reactive programming in Java - Codemotion Milan 2017Mario Fusco - Reactive programming in Java - Codemotion Milan 2017
Mario Fusco - Reactive programming in Java - Codemotion Milan 2017Codemotion
 
Actors or Not: Async Event Architectures
Actors or Not: Async Event ArchitecturesActors or Not: Async Event Architectures
Actors or Not: Async Event ArchitecturesYaroslav Tkachenko
 
The End of a Myth: Ultra-Scalable Transactional Management
The End of a Myth: Ultra-Scalable Transactional ManagementThe End of a Myth: Ultra-Scalable Transactional Management
The End of a Myth: Ultra-Scalable Transactional ManagementRicardo Jimenez-Peris
 

Similaire à Multi-service reactive streams using Spring, Reactor, RSocket (20)

Reactive Programming in Java and Spring Framework 5
Reactive Programming in Java and Spring Framework 5Reactive Programming in Java and Spring Framework 5
Reactive Programming in Java and Spring Framework 5
 
HBaseCon2017 Highly-Available HBase
HBaseCon2017 Highly-Available HBaseHBaseCon2017 Highly-Available HBase
HBaseCon2017 Highly-Available HBase
 
Reactive Streams 1.0.0 and Why You Should Care (webinar)
Reactive Streams 1.0.0 and Why You Should Care (webinar)Reactive Streams 1.0.0 and Why You Should Care (webinar)
Reactive Streams 1.0.0 and Why You Should Care (webinar)
 
Reactive solutions using java 9 and spring reactor
Reactive solutions using java 9 and spring reactorReactive solutions using java 9 and spring reactor
Reactive solutions using java 9 and spring reactor
 
Flexible and Real-Time Stream Processing with Apache Flink
Flexible and Real-Time Stream Processing with Apache FlinkFlexible and Real-Time Stream Processing with Apache Flink
Flexible and Real-Time Stream Processing with Apache Flink
 
Architectural Patterns - Interactive and Event Handling Patterns
Architectural Patterns  - Interactive and Event Handling PatternsArchitectural Patterns  - Interactive and Event Handling Patterns
Architectural Patterns - Interactive and Event Handling Patterns
 
Guide to Spring Reactive Programming using WebFlux
Guide to Spring Reactive Programming using WebFluxGuide to Spring Reactive Programming using WebFlux
Guide to Spring Reactive Programming using WebFlux
 
Server system architecture
Server system architectureServer system architecture
Server system architecture
 
Reactive mesh
Reactive meshReactive mesh
Reactive mesh
 
Journey into Reactive Streams and Akka Streams
Journey into Reactive Streams and Akka StreamsJourney into Reactive Streams and Akka Streams
Journey into Reactive Streams and Akka Streams
 
Reactive Spring 5
Reactive Spring 5Reactive Spring 5
Reactive Spring 5
 
SenchaCon 2016: How to Give your Sencha App Real-time Web Performance - James...
SenchaCon 2016: How to Give your Sencha App Real-time Web Performance - James...SenchaCon 2016: How to Give your Sencha App Real-time Web Performance - James...
SenchaCon 2016: How to Give your Sencha App Real-time Web Performance - James...
 
CHP-4.pptx
CHP-4.pptxCHP-4.pptx
CHP-4.pptx
 
Remote Procedure Call
Remote Procedure CallRemote Procedure Call
Remote Procedure Call
 
5 application serversforproject
5 application serversforproject5 application serversforproject
5 application serversforproject
 
Kafka summit SF 2019 - the art of the event-streaming app
Kafka summit SF 2019 - the art of the event-streaming appKafka summit SF 2019 - the art of the event-streaming app
Kafka summit SF 2019 - the art of the event-streaming app
 
The art of the event streaming application: streams, stream processors and sc...
The art of the event streaming application: streams, stream processors and sc...The art of the event streaming application: streams, stream processors and sc...
The art of the event streaming application: streams, stream processors and sc...
 
Mario Fusco - Reactive programming in Java - Codemotion Milan 2017
Mario Fusco - Reactive programming in Java - Codemotion Milan 2017Mario Fusco - Reactive programming in Java - Codemotion Milan 2017
Mario Fusco - Reactive programming in Java - Codemotion Milan 2017
 
Actors or Not: Async Event Architectures
Actors or Not: Async Event ArchitecturesActors or Not: Async Event Architectures
Actors or Not: Async Event Architectures
 
The End of a Myth: Ultra-Scalable Transactional Management
The End of a Myth: Ultra-Scalable Transactional ManagementThe End of a Myth: Ultra-Scalable Transactional Management
The End of a Myth: Ultra-Scalable Transactional Management
 

Plus de Stéphane Maldini

The Future of Reactive Architectures
The Future of Reactive ArchitecturesThe Future of Reactive Architectures
The Future of Reactive ArchitecturesStéphane Maldini
 
What's new in Reactor Californium
What's new in Reactor CaliforniumWhat's new in Reactor Californium
What's new in Reactor CaliforniumStéphane Maldini
 
Spring boot 2.0 reactive bits (June 2018)
Spring boot 2.0 reactive bits (June 2018)Spring boot 2.0 reactive bits (June 2018)
Spring boot 2.0 reactive bits (June 2018)Stéphane Maldini
 
Reactor 3.0, a reactive foundation for java 8 and Spring
Reactor 3.0, a reactive foundation for java 8 and SpringReactor 3.0, a reactive foundation for java 8 and Spring
Reactor 3.0, a reactive foundation for java 8 and SpringStéphane Maldini
 
Introduction to Reactive Streams and Reactor 2.5
Introduction to Reactive Streams and Reactor 2.5Introduction to Reactive Streams and Reactor 2.5
Introduction to Reactive Streams and Reactor 2.5Stéphane Maldini
 
Intro to Reactive Programming
Intro to Reactive ProgrammingIntro to Reactive Programming
Intro to Reactive ProgrammingStéphane Maldini
 
Designing for Distributed Systems with Reactor and Reactive Streams
Designing for Distributed Systems with Reactor and Reactive StreamsDesigning for Distributed Systems with Reactor and Reactive Streams
Designing for Distributed Systems with Reactor and Reactive StreamsStéphane Maldini
 
Reactor, Reactive streams and MicroServices
Reactor, Reactive streams and MicroServicesReactor, Reactive streams and MicroServices
Reactor, Reactive streams and MicroServicesStéphane Maldini
 
Reactor grails realtime web devoxx 2013
Reactor grails realtime web   devoxx 2013Reactor grails realtime web   devoxx 2013
Reactor grails realtime web devoxx 2013Stéphane Maldini
 
Groovy reactor grails realtime web devoxx 2013
Groovy reactor grails realtime web   devoxx 2013Groovy reactor grails realtime web   devoxx 2013
Groovy reactor grails realtime web devoxx 2013Stéphane Maldini
 
Reactor spring one2gx_2013_0902-final
Reactor spring one2gx_2013_0902-finalReactor spring one2gx_2013_0902-final
Reactor spring one2gx_2013_0902-finalStéphane Maldini
 

Plus de Stéphane Maldini (14)

The Future of Reactive Architectures
The Future of Reactive ArchitecturesThe Future of Reactive Architectures
The Future of Reactive Architectures
 
Spring Cloud Gateway
Spring Cloud GatewaySpring Cloud Gateway
Spring Cloud Gateway
 
What's new in Reactor Californium
What's new in Reactor CaliforniumWhat's new in Reactor Californium
What's new in Reactor Californium
 
Spring boot 2.0 reactive bits (June 2018)
Spring boot 2.0 reactive bits (June 2018)Spring boot 2.0 reactive bits (June 2018)
Spring boot 2.0 reactive bits (June 2018)
 
Reactor 3.0, a reactive foundation for java 8 and Spring
Reactor 3.0, a reactive foundation for java 8 and SpringReactor 3.0, a reactive foundation for java 8 and Spring
Reactor 3.0, a reactive foundation for java 8 and Spring
 
Introduction to Reactive Streams and Reactor 2.5
Introduction to Reactive Streams and Reactor 2.5Introduction to Reactive Streams and Reactor 2.5
Introduction to Reactive Streams and Reactor 2.5
 
Intro to Reactive Programming
Intro to Reactive ProgrammingIntro to Reactive Programming
Intro to Reactive Programming
 
Designing for Distributed Systems with Reactor and Reactive Streams
Designing for Distributed Systems with Reactor and Reactive StreamsDesigning for Distributed Systems with Reactor and Reactive Streams
Designing for Distributed Systems with Reactor and Reactive Streams
 
Reactor, Reactive streams and MicroServices
Reactor, Reactive streams and MicroServicesReactor, Reactive streams and MicroServices
Reactor, Reactive streams and MicroServices
 
Reactor grails realtime web devoxx 2013
Reactor grails realtime web   devoxx 2013Reactor grails realtime web   devoxx 2013
Reactor grails realtime web devoxx 2013
 
Groovy reactor grails realtime web devoxx 2013
Groovy reactor grails realtime web   devoxx 2013Groovy reactor grails realtime web   devoxx 2013
Groovy reactor grails realtime web devoxx 2013
 
Ss2gx
Ss2gxSs2gx
Ss2gx
 
Reactor spring one2gx_2013_0902-final
Reactor spring one2gx_2013_0902-finalReactor spring one2gx_2013_0902-final
Reactor spring one2gx_2013_0902-final
 
Eventsggx
EventsggxEventsggx
Eventsggx
 

Dernier

Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsJhone kinadey
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationShrmpro
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyviewmasabamasaba
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...SelfMade bd
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Hararemasabamasaba
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastPapp Krisztián
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnAmarnathKambale
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park masabamasaba
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburgmasabamasaba
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...Nitya salvi
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareJim McKeeth
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...masabamasaba
 

Dernier (20)

Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
%in Hazyview+277-882-255-28 abortion pills for sale in Hazyview
 
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
Crypto Cloud Review - How To Earn Up To $500 Per DAY Of Bitcoin 100% On AutoP...
 
%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare%in Harare+277-882-255-28 abortion pills for sale in Harare
%in Harare+277-882-255-28 abortion pills for sale in Harare
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
VTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learnVTU technical seminar 8Th Sem on Scikit-learn
VTU technical seminar 8Th Sem on Scikit-learn
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
%in Lydenburg+277-882-255-28 abortion pills for sale in Lydenburg
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 

Multi-service reactive streams using Spring, Reactor, RSocket

  • 1. Multi-Service Reactive Streams using RSocket, Reactor, and Spring Ben Hale, Cloud Foundry Java Experience Lead @nebhale Stephane Maldini, Project Reactor Lead @smaldini
  • 2. Reactive Programming • Reactive programming is the next frontier in Java for high-efficiency applications • Fundamentally non-blocking and often paired with asynchronous behaviors • Reactive has no opinion on async and many flows are totally synchronous • Key differentiator from "async" is Reactive (pull-push) back pressure
  • 3. WebFlux and WebClient @GetMapping("/health") Mono<Health> compositeHealth() { return Mono.zip( webClient.get().uri("https://alpha-service/health") .retrieve().bodyToMono(Health.class), webClient.get().uri("https://bravo-service/health") .retrieve().bodyToMono(Health.class)) .map(t -> composite(t.getT1(), t.getT2())); }
  • 4. Roadblocks • But there are still some barriers to using Reactive everywhere* • Data Access • MongoDB, Apache Cassandra, and Redis • No relational database access • Cross-process back pressure (networking)
  • 5. Roadblocks • But there are still some barriers to using Reactive everywhere* • Data Access • MongoDB, Apache Cassandra, and Redis • No relational database access • Cross-process back pressure (networking) Until R2DBC ! Check out r2dbc.io • No relational database access
  • 7. Message Driven Binary Protocol • Requester-Responder interaction is broken down into frames that encapsulate messages • The framing is binary (not human readable like JSON or XML) • Massive efficiencies for machine-to-machine communication • Downsides only manifest rarely and can be mitigated with tooling • Payloads are bags of bytes • Can be JSON or XML (it's all just 1's and 0's)
  • 8.
  • 19. Bi-Directional • Many protocols (notably not TCP) have a distinction between the client and server for the lifetime of a connection • This division means that one side of the connection must initiate all requests, and the other side must initiate all responses • Even more flexible protocols like HTTP/2 do not fully drop the distinction • Servers cannot start an unrequested stream of data to the client • Once a client initiates a connection to a server, both parties can be requestors or responders to a logical stream
  • 25. Reactive Streams Back Pressure • Network protocols generally send a single request, and receive an arbitrarily large response in return • There is nothing to stop the responder (or even the requestor) from sending an arbitrarily large amount of data and overwhelming the receiver • In cases where TCP back pressure throttles the responder, queues fill with large amounts of un-transferred data • Reactive Streams (pull-push) back pressure ensures that data is only materialized and transferred when receiver is ready to process it
  • 26. 20 0
  • 29. 3 22
  • 32. 3 22
  • 36. Resumption/Resumability • Starting as a client-to-edge-server protocol highlighted a common failing of existing options • Clients on unstable connections would often drop and need to re-establish current state • Led to inefficiencies in both network traffic and data-center compute • Resumability allows both parties in a "logical connection" to identify themselves on reconnection • On Resumption both parties handshake about the last frame received and all missed frames are re-transmitted • Frame caching to support is not defined by spec so it can be very flexible 36
  • 37.
  • 39. compose with no semantics loss 🔎 🔎 🔎 ws tcp udp
  • 40. RSocket Protocol TCP WebSocket Aeron/UDPHTTP/2 Protobuf JSON Custom Binary RPC-style Messaging Java JavaScript C++ Kotlin Flow
  • 42. Java API public interface RSocket { Mono<Payload> requestResponse(Payload payload); Mono<Void> fireAndForget(Payload payload); Flux<Payload> requestStream(Payload payload); Flux<Payload> requestChannel(Flux<Payload> payloads); }
  • 43. Java API public interface RSocket { Mono<Payload> requestResponse(Payload payload); Mono<Void> fireAndForget(Payload payload); Flux<Payload> requestStream(Payload payload); Flux<Payload> requestChannel(Flux<Payload> payloads); }
  • 44. Interaction Models – Request-Response Mono<Payload> resp = client.requestResponse(requestPayload) • Standard Request-Response semantics • Likely to represent the majority of requests for the foreseeable future • Even this obvious interaction model surpasses HTTP because it is asynchronous and multiplexed • Request with account number, respond with account balance
  • 45. Interaction Models – Fire-and-Forget Mono<Void> resp = client.fireAndForget(requestPayload) • An optimization of Request-Response when a response isn't necessary • Significant efficiencies • Networking (no ack) • Client/Server processing (immediate release of resources) • Non-critical event logging
  • 46. Interaction Models – Request-Stream Flux<Payload> resp = client.requestStream(requestPayload) • Analogous to Request-Response returning a collection • The collection is streamed back instead of queuing until complete • RequestN semantics mean data is not materialized until ready to send • Request with account number, respond with real-time stream of account transactions
  • 47. Interaction Models – Channel Flux<Payload> out = client.requestChannel(Flux<Payload> in) • A bi-directional stream of messages in both directions • An unstructured channel allows arbitrary interaction models • Request burst of initial state, listen for subsequent updates, client updates subscription without starting new connection • Request with account number, respond with real-time stream of account transactions, update subscription to filter certain transaction types, respond with filtered real-time stream of account transactions
  • 48. Raw Client RSocket client = RSocketFactory.connect() .transport(TcpClientTransport.create("1.2.3.4", 80)) .start() .block();
  • 49. Raw Client RSocket client = RSocketFactory.connect() .transport(TcpClientTransport.create("1.2.3.4", 80)) .start() .block(); client.requestResponse(new DefaultPayload(…)) .doOnComplete(() -> System.out.println(“hooray”) .subscribe();
  • 50. Raw Client RSocket client = RSocketFactory.connect() .transport(TcpClientTransport.create("1.2.3.4", 80)) .start() .block(); client.requestResponse(new DefaultPayload(…)) .doOnComplete(() -> System.out.println(“hooray”) .subscribe(); Censored ByteBuffer creation
  • 51. Raw Client Too Low Level ?
 Shift to the next gear with existing tech built on RSocket 😱
  • 52. Building applications with RSocket API • Programming Model Agnostic • The RSocket interface is a serviceable programming model but not great • Designed to be a building block that multiple other programming models could build upon
  • 53. Building applications with RSocket API • Making things simpler: • RPC-style (protobuf code generation) • Messaging-style (Spring message handlers/controllers)
  • 54. RPC-style (Contract Driven) service RecordsService { rpc records (RecordsRequest) returns (stream Record) {} }
  • 55. RPC-style (Contract Driven) service RecordsService { rpc records (RecordsRequest) returns (stream Record) {} } RecordsServiceClient rankingService = new RecordsServiceClient(rsocket); recordsService.records(RecordsRequest.newBuilder() .setMaxResults(16) .build()) .subscribe(record -> System.out.println(record));
  • 56. RPC-style (Contract Driven) service RecordsService { rpc records (RecordsRequest) returns (stream Record) {} } RecordsServiceClient rankingService = new RecordsServiceClient(rsocket); recordsService.records(RecordsRequest.newBuilder() .setMaxResults(16) .build()) .subscribe(record -> System.out.println(record)); You still need to manage this part
  • 57. RPC-style (Contract Driven) service RecordsService { rpc records (RecordsRequest) returns (stream Record) {} }
  • 58. RPC-style (Contract Driven) service RecordsService { rpc records (RecordsRequest) returns (stream Record) {} } let recordServiceClient = new RecordsServiceClient(rsocket); let req = new RecordRequest(); req.setMaxResults(16); recordServiceClient.records(req) .subscribe();
  • 59. Messaging-Style static class TestHandler implements RSocketHandler { @MessageMapping("/canonical") Mono<String> handleCanonical(String payload) { return Mono.delay(Duration.ofMillis(10)) .map(l -> createResponse(payload)); } @MessageMapping("/async-arg") Mono<String> handleMonoArg(Mono<String> payload) { return payload.map(ServerResponderApp::createResponse); } }
  • 61. Metadata and Data in Frames • Each Frame has an optional metadata payload • The metadata payload has a MIME-Type but is otherwise unstructured • Very flexible • Can be used to carry metadata about the data payload • Can be used to carry metadata in order to decode the payload • Generally means that payloads can be heterogenous and each message decoded uniquely
  • 62. Fragmentation • Payload frames have no maximum size • The protocol is well suited to serving large payloads • Still Images (Facebook), Video (Netflix) • Both TCP MTUs and reliability on slow connections lead towards smaller payloads • Fragmentation provides a way to continue to reason about "logical frames" while ensuring that individual payloads are smaller • Applied transparently, after enforcement of RequestN semantics
  • 63. Cancellation • All interaction types support cancellation • Cancellation is a signal by the requestor that any inflight processing should be terminated eagerly and aggressively • An obvious requirement for Request-Stream and Channel • But useful even in Request-Response where the response can be expensive to generate • Early termination can lead to significant improvement in efficiency
  • 64. Leasing • Reactive back pressure ensures that a responder (or either party in a Channel) cannot overwhelm the receiver • This does not prevent a requestor from overwhelming a responder • This commonly happens in server-to-server environments where throughput is high • Leasing enables responders to signal capacity to requestors • This signal is useful for client-side load-balancing • Without preventing server-side load-balancing
  • 65. RSocket • RSocket is a bi-directional, multiplexed, message-based, binary protocol • Utilizes Reactive Streams back pressure for efficiency and predictability • Provides primitives for the four common interaction models • Flexibility in transport, payload, language, and programming model • Let us know which programming model you prefer! • Myriad other features that make it great for modern application-to- application communication