SlideShare a Scribd company logo
© Copyright 2017 Pivotal Software, Inc. All rights Reserved. Version 1.0
Reactor in Action
Victor Grazi
Simon Baslé
Victor Grazi
VP Core Technologies
Nomura Securities
&
@vgrazi
Simon Baslé
@simonbasle
Staff Software Engineer
Pivotal (Project Reactor)
Agenda
Part 1 : Reactive
Programming 101
Part 2 : Core In Action
Part 3 : Advanced
Features
Part 4 : Use In Spring
● What is Reactive?
● Flux basics
● Marble diagrams
● Cold Fluxes
● Hot Fluxes
Agenda
Part 1 : Reactive
Programming 101
Part 2 : Core In Action
Part 3 : Advanced
Features
Part 4 : Use In Spring
● Count Letter In Phrases Demo
● Temporal Dimension Demo
Agenda
Part 1 : Reactive
Programming 101
Part 2 : Core In Action
Part 3 : Advanced
Features
Part 4 : Use In Spring
● Hot Sequence Demo
● Testing and Debugging Demos
Agenda
Part 1 : Reactive
Programming 101
Part 2 : Core In Action
Part 3 : Advanced
Features
Part 4 : Use In Spring
● Spring WebFlux Controller Demo
● WebClient Demo
Reactive Programming
101
What Is Reactive
Programming
What Is Reactive
Programming
An Alternate programming paradigm
What Is Reactive
Programming
Simplify Clean Coding of Asynchronous Event-Driven
programs
What Is Reactive
Programming
Declarative tools for Concise, Error-Free code
especially under High Load and Concurrency
What Is Reactive
Programming
The Reactive Streams Specification
Original Problem
Merging Many Requests
NetflixAPI
Server Request Latency Network Latency
Device
Server
Get/Test it on Maven
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-core</artifactId>
<version>3.1.1.RELEASE</version>
</dependency>
Get/Test it on Maven
<dependency>
<groupId>io.projectreactor</groupId>
<artifactId>reactor-test</artifactId>
<version>3.1.1.RELEASE</version>
<scope>test</scope>
</dependency>
Get/Test it on Gradle
dependencies {
compile “io.projectreactor:reactor-core:3.1.1.RELEASE”
testCompile “io.projectreactor:reactor-test:3.1.1.RELEASE”
}
Basic Model
Flux Subscriber
Basic Model
Everything is a stream of messages
Flux Subscriber
Basic Model
Flux<T> emits event messages
Flux Subscriber
Basic Model
Subscriber consumes messages
Flux Subscriber
Message Streams of...
Computations
Query Results
Even Errors !
Events
SubscriberA
onNext(T)
onComplete()
onError(Throwable)
Receives Notifications
onNext(T)
onComplete()
onError(Throwable)
terminal
events
SubscriberA Receives Notifications
SubscriberA Needs to be Attached
flux.subscribe(
subscriber
)
flux.subscribe(
value -> handleHappyPath(value),
error -> handleError(error),
() -> handleCompletion()
)
SubscriberA Needs to be Attached
Optional but
recommended Optional
SubscriberA Needs to be Attached
flux.subscribe(
value -> handleHappyPath(value),
error -> handleError(error),
() -> handleCompletion()
)
Compose &
transform
Using the APIFlux
persons.filter(person -> person.isAdult())
.subscribe();
Compose &
transform
Using the APIFlux
persons.map(person -> person.name())
.subscribe();
Compose &
transform
Using the APIFlux
persons.filter(person -> person.isAdult())
.map(person -> person.name())
.subscribe();
Compose &
transform
Using the APIFlux
Flux<Person> persons = ...;
Flux<Person> adults =
persons.filter(Person::isAdult);
Flux<String> adultNames =
adults.map(Person::name);
...
Each Operator returns a new Flux
Marble Diagrams
Marble Diagrams
Interactive marble diagrams on http://rxmarbles.com/
(most map to Reactor operators)
Combine
Examples:
merge(...), zip(...), first(...)
Combine
Combine
Create
Examples:
Flux.just(value)
Flux.fromIterable(list)
Flux.range(i, n)
Flux.interval(Duration.ofSeconds(n))
...
Transform
Examples:
take(n), skip(n)
Transform
Transform
Other Transforms
Flux.filter(x -> condition)
Flux.map(Some::mapper)
Flux.flatMap(Some::mapperToFlux)
...
Difference between map and flatMap?
Map
Transforms 1 source element into 1
output element
Does nothing particular other
than the transformation from T to V
Transformation is “synchronous”
Returns a Flux<V>
FlatMap
Transforms 1 source element into
a Flux of N elements
Subscribes to each generated
Flux<V> then flattens their values
Transformation can be async
Returns a Flux<V>
By the way: Difference between Stream
and Reactor APIs?
Functional-style API
to process a
Collection or
in-memory data
once.
Functional-style API
to process any sort
of data (including
asynchronously
generated data),
possibly multiple
times.
Java Stream
Functional-style API to process a Collection
or in-memory data once.
● Pull based
● Basically a way to iterate collections
declaratively
● Generally synchronous data
● Streams can only be used once
● No flow-control
● No control of timing
● No composition of streams
● Finite amount of data
Flux / Mono
Functional-style API to process any sort of
data (including asynchronously generated
data), possibly multiple times.
● Push based
● Real-time data, latency, concurrency,
flow control
● Asynchronous-friendly
● Reactive streams are highly reusable
● Back-pressure strategies
● Time-aware
● Advanced composition/transformation
● Data sizes from zero to infinity
Concurrency Footnotes
Schedulers Abstraction
Concurrency Footnotes
Concurrent Agnostic
Concurrency Footnotes
Influence Execution
with publishOn and subscribeOn
Cold vs Hot
Cold Flux
● Won’t start pumping until there’s a Subscriber
attached
● Will emit the whole data set to each new Subscriber
Cold vs Hot
Hot Flux
● Generally reads live data, eg. data feeds or mouse
movements
● Begins pumping on connection (possibly on creation)
● Each Subscriber only gets the newest data from the
point where they attach
Creating Hot Flux
ConnectableFlux<Long> hotFlux =
coldFlux.publish();
hotFlux.subscribe(System.out::println);
hotFlux.subscribe(System.out::println);
hotFlux.connect();
Both will see
all the data
Creating Hot Flux
1st will see all the
data
2nd might only see
part of the data
ConnectableFlux<Long> hotFlux =
coldFlux.publish();
hotFlux.subscribe(System.out::println);
hotFlux.connect();
hotFlux.subscribe(System.out::println);
Core In Action
Live Coding
Advanced Features
Live Coding
Use In Spring
Live Coding
The end
Thank You!
Questions?

More Related Content

PDF
Project Reactor Now and Tomorrow
PDF
Reactive programming with Pivotal's reactor
PPTX
Designing, Implementing, and Using Reactive APIs
PDF
Servlet or Reactive Stacks: The Choice is Yours. Oh No...The Choice is Mine!
PDF
RxJava - introduction & design
PDF
Reactive Programming in Java and Spring Framework 5
PPTX
Introduction to Reactive Java
PDF
Understanding and Extending Prometheus AlertManager
Project Reactor Now and Tomorrow
Reactive programming with Pivotal's reactor
Designing, Implementing, and Using Reactive APIs
Servlet or Reactive Stacks: The Choice is Yours. Oh No...The Choice is Mine!
RxJava - introduction & design
Reactive Programming in Java and Spring Framework 5
Introduction to Reactive Java
Understanding and Extending Prometheus AlertManager

What's hot (19)

PPTX
Reactive Programming in Java 8 with Rx-Java
PDF
rx-java-presentation
PPTX
Javantura v3 - ES6 – Future Is Now – Nenad Pečanac
PDF
Asynchronous stream processing with Akka Streams
PDF
Microservices with Netflix OSS & Spring Cloud - Arnaud Cogoluègnes
PDF
Bulding a reactive game engine with Spring 5 & Couchbase
PDF
Streaming all the things with akka streams
PDF
Modern app programming with RxJava and Eclipse Vert.x
PDF
Machine learning with Apache Spark on Kubernetes | DevNation Tech Talk
PDF
Microservices with Netflix OSS and Spring Cloud
PDF
How to monitor your micro-service with Prometheus?
PDF
Akka streams - Umeå java usergroup
PPTX
Java 7 & 8
PDF
Akka-chan's Survival Guide for the Streaming World
PDF
Monitoring kubernetes with prometheus
PDF
MuleSoft Manchester Meetup #3 slides 31st March 2020
PDF
Brief intro to K8s controller and operator
PPT
Reactive programming with examples
PPTX
Real world functional reactive programming
Reactive Programming in Java 8 with Rx-Java
rx-java-presentation
Javantura v3 - ES6 – Future Is Now – Nenad Pečanac
Asynchronous stream processing with Akka Streams
Microservices with Netflix OSS & Spring Cloud - Arnaud Cogoluègnes
Bulding a reactive game engine with Spring 5 & Couchbase
Streaming all the things with akka streams
Modern app programming with RxJava and Eclipse Vert.x
Machine learning with Apache Spark on Kubernetes | DevNation Tech Talk
Microservices with Netflix OSS and Spring Cloud
How to monitor your micro-service with Prometheus?
Akka streams - Umeå java usergroup
Java 7 & 8
Akka-chan's Survival Guide for the Streaming World
Monitoring kubernetes with prometheus
MuleSoft Manchester Meetup #3 slides 31st March 2020
Brief intro to K8s controller and operator
Reactive programming with examples
Real world functional reactive programming
Ad

Similar to Reactor in Action (20)

PDF
Journey into Reactive Streams and Akka Streams
PPTX
Functional Programming in Java
PPTX
Talk Python To Me: Stream Processing in your favourite Language with Beam on ...
PPTX
Reactive programming by spring webflux - DN Scrum Breakfast - Nov 2018
PDF
Stream Processing in the Cloud - Athens Kubernetes Meetup 16.07.2019
PPTX
Reactive Spring 5
PDF
Flink Forward Berlin 2017: Aljoscha Krettek - Talk Python to me: Stream Proce...
PPTX
Андрій Рева, "How to build reactive java application"
PDF
Apache Zeppelin on Kubernetes with Spark and Kafka - meetup @twitter
PPTX
Reactive programming for java developers
PDF
Making our Future better
PDF
Running Flink in Production: The good, The bad and The in Between - Lakshmi ...
PDF
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
PDF
Flink Forward Berlin 2018: Thomas Weise & Aljoscha Krettek - "Python Streamin...
PDF
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
PDF
Serverless Spring by Stephane Maldini
PPTX
Stream processing from single node to a cluster
PPTX
Introduction to Reactive programming
PDF
Webinar about Spring Data Neo4j 4
PPTX
Reactive Java: Promises and Streams with Reakt (JavaOne talk 2016)
Journey into Reactive Streams and Akka Streams
Functional Programming in Java
Talk Python To Me: Stream Processing in your favourite Language with Beam on ...
Reactive programming by spring webflux - DN Scrum Breakfast - Nov 2018
Stream Processing in the Cloud - Athens Kubernetes Meetup 16.07.2019
Reactive Spring 5
Flink Forward Berlin 2017: Aljoscha Krettek - Talk Python to me: Stream Proce...
Андрій Рева, "How to build reactive java application"
Apache Zeppelin on Kubernetes with Spark and Kafka - meetup @twitter
Reactive programming for java developers
Making our Future better
Running Flink in Production: The good, The bad and The in Between - Lakshmi ...
ClojureScript - Making Front-End development Fun again - John Stevenson - Cod...
Flink Forward Berlin 2018: Thomas Weise & Aljoscha Krettek - "Python Streamin...
Progscon 2017: Taming the wild fronteer - Adventures in Clojurescript
Serverless Spring by Stephane Maldini
Stream processing from single node to a cluster
Introduction to Reactive programming
Webinar about Spring Data Neo4j 4
Reactive Java: Promises and Streams with Reakt (JavaOne talk 2016)
Ad

More from VMware Tanzu (20)

PDF
Spring into AI presented by Dan Vega 5/14
PDF
What AI Means For Your Product Strategy And What To Do About It
PDF
Make the Right Thing the Obvious Thing at Cardinal Health 2023
PPTX
Enhancing DevEx and Simplifying Operations at Scale
PDF
Spring Update | July 2023
PPTX
Platforms, Platform Engineering, & Platform as a Product
PPTX
Building Cloud Ready Apps
PDF
Spring Boot 3 And Beyond
PDF
Spring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdf
PDF
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
PDF
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
PPTX
tanzu_developer_connect.pptx
PDF
Tanzu Virtual Developer Connect Workshop - French
PDF
Tanzu Developer Connect Workshop - English
PDF
Virtual Developer Connect Workshop - English
PDF
Tanzu Developer Connect - French
PDF
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
PDF
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
PDF
SpringOne Tour: The Influential Software Engineer
PDF
SpringOne Tour: Domain-Driven Design: Theory vs Practice
Spring into AI presented by Dan Vega 5/14
What AI Means For Your Product Strategy And What To Do About It
Make the Right Thing the Obvious Thing at Cardinal Health 2023
Enhancing DevEx and Simplifying Operations at Scale
Spring Update | July 2023
Platforms, Platform Engineering, & Platform as a Product
Building Cloud Ready Apps
Spring Boot 3 And Beyond
Spring Cloud Gateway - SpringOne Tour 2023 Charles Schwab.pdf
Simplify and Scale Enterprise Apps in the Cloud | Boston 2023
Simplify and Scale Enterprise Apps in the Cloud | Seattle 2023
tanzu_developer_connect.pptx
Tanzu Virtual Developer Connect Workshop - French
Tanzu Developer Connect Workshop - English
Virtual Developer Connect Workshop - English
Tanzu Developer Connect - French
Simplify and Scale Enterprise Apps in the Cloud | Dallas 2023
SpringOne Tour: Deliver 15-Factor Applications on Kubernetes with Spring Boot
SpringOne Tour: The Influential Software Engineer
SpringOne Tour: Domain-Driven Design: Theory vs Practice

Recently uploaded (20)

PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PPTX
Tartificialntelligence_presentation.pptx
PPTX
Chapter 5: Probability Theory and Statistics
PPTX
A Presentation on Touch Screen Technology
PDF
Web App vs Mobile App What Should You Build First.pdf
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PDF
A comparative analysis of optical character recognition models for extracting...
PDF
Mushroom cultivation and it's methods.pdf
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
PDF
Assigned Numbers - 2025 - Bluetooth® Document
PDF
WOOl fibre morphology and structure.pdf for textiles
PDF
Unlocking AI with Model Context Protocol (MCP)
PPTX
Programs and apps: productivity, graphics, security and other tools
PDF
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
PDF
Univ-Connecticut-ChatGPT-Presentaion.pdf
PPTX
1. Introduction to Computer Programming.pptx
PPTX
cloud_computing_Infrastucture_as_cloud_p
PPTX
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Digital-Transformation-Roadmap-for-Companies.pptx
Tartificialntelligence_presentation.pptx
Chapter 5: Probability Theory and Statistics
A Presentation on Touch Screen Technology
Web App vs Mobile App What Should You Build First.pdf
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
A comparative analysis of optical character recognition models for extracting...
Mushroom cultivation and it's methods.pdf
SOPHOS-XG Firewall Administrator PPT.pptx
Video forgery: An extensive analysis of inter-and intra-frame manipulation al...
Assigned Numbers - 2025 - Bluetooth® Document
WOOl fibre morphology and structure.pdf for textiles
Unlocking AI with Model Context Protocol (MCP)
Programs and apps: productivity, graphics, security and other tools
Transform Your ITIL® 4 & ITSM Strategy with AI in 2025.pdf
Univ-Connecticut-ChatGPT-Presentaion.pdf
1. Introduction to Computer Programming.pptx
cloud_computing_Infrastucture_as_cloud_p
TechTalks-8-2019-Service-Management-ITIL-Refresh-ITIL-4-Framework-Supports-Ou...
gpt5_lecture_notes_comprehensive_20250812015547.pdf

Reactor in Action