Reactor 3.0, a reactive foundation for java 8 and Spring
-
Upload
stephane-maldini -
Category
Software
-
view
1.870 -
download
0
Transcript of Reactor 3.0, a reactive foundation for java 8 and Spring
![Page 1: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/1.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Reactor 3. Reactive Foundation for Java 8 and Spring
Stephane Maldini @smaldini
![Page 2: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/2.jpg)
Reactive ?
![Page 3: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/3.jpg)
Reactive ?
![Page 5: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/5.jpg)
Publisher Subscriber
Reactive Streamsreactive-streams.org
Standard definition
![Page 6: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/6.jpg)
Publisher Subscriber
Reactive Streamsreactive-streams.org
Standard definition0..N Data + 0..1 (Error | Complete)
![Page 7: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/7.jpg)
Publisher Subscriber
Backpressure
Reactive Streamsreactive-streams.org
Standard definition0..N Data + 0..1 (Error | Complete)
![Page 8: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/8.jpg)
Publisher Subscriber
Backpressure
Reactive Streamsreactive-streams.org
Standard definition0..N Data + 0..1 (Error | Complete)
![Page 9: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/9.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Reactor Core provides for a minimalist set of Reactive Streams ready
generators and transformers
4
![Page 10: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/10.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Reactor Core provides for a minimalist set of Reactive Streams ready
generators and transformers
4
WHY ?
![Page 11: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/11.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 / 5
DIY Reactive Streams
Publisher<User> rickSanchez = userRepository.findUser(“rick”);
![Page 12: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/12.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 / 5
DIY Reactive Streams
Publisher<User> rickSanchez = userRepository.findUser(“rick”);
Produce User when ready
![Page 13: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/13.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 / 5
DIY Reactive Streams
Publisher<User> rickSanchez = userRepository.findUser(“rick”);
Might produce 0, 1 or N Users ! Produce User when ready
![Page 14: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/14.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 / 5
DIY Reactive Streams
Publisher<User> rickSanchez = userRepository.findUser(“rick”);
Might produce 0, 1 or N Users ! Produce User when ready
rickSanchez.subscribe(new Subscriber<User>(){ … });
![Page 15: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/15.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 / 5
DIY Reactive Streams
Publisher<User> rickSanchez = userRepository.findUser(“rick”);
Might produce 0, 1 or N Users ! Produce User when ready
Callback for start, result, error or complete
rickSanchez.subscribe(new Subscriber<User>(){ … });
![Page 16: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/16.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
DIY Reactive Streams
6
![Page 17: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/17.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
DIY Reactive Streams
6
Can I have an API ?
![Page 18: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/18.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
DIY Reactive Streams - top issues
• Should Work with RS TCK • Address reentrance • Address thread safety • Address efficiency • Address state • For Many-To-One flows, implement your own merging operation • For One-To-Many lows, implement your own broadcasting operation • ….
7
![Page 19: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/19.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
DIY Reactive Streams - top issues
• Should Work with RS TCK • Address reentrance • Address thread safety • Address efficiency • Address state • For Many-To-One flows, implement your own merging operation • For One-To-Many lows, implement your own broadcasting operation • ….
7
![Page 20: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/20.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 / 8
![Page 21: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/21.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
3 years to mature
9
R e a c t i v e S t r e a m s C o m m o n s
I P C
A D D O N S
S p r i n g R x
C O R E
2013: 1.x 2014: 2.x 2016: 3.0
![Page 22: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/22.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
3 years to mature
9
R e a c t i v e S t r e a m s C o m m o n s
I P C
A D D O N S
S p r i n g R x
C O R E
Existential questions
2013: 1.x 2014: 2.x 2016: 3.0
![Page 23: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/23.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
3 years to mature
9
R e a c t i v e S t r e a m s C o m m o n s
I P C
A D D O N S
S p r i n g R x
C O R E
Existential questions
2013: 1.x 2014: 2.x 2016: 3.0
Microservices become the norm
![Page 24: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/24.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
3 years to mature
9
R e a c t i v e S t r e a m s C o m m o n s
I P C
A D D O N S
S p r i n g R x
C O R E
Existential questions
2013: 1.x 2014: 2.x 2016: 3.0
Microservices become the norm
Rocky style revival
![Page 25: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/25.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
3x Influences and Collaborations
10
R e a c t i v e S t r e a m s C o m m o n s
I P C
A D D O N S
S p r i n g R x
C O R E
![Page 26: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/26.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
3x Influences and Collaborations
10
R e a c t i v e S t r e a m s C o m m o n s
I P C
A D D O N S
S p r i n g R x
C O R E
![Page 27: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/27.jpg)
Flux
![Page 28: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/28.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Flux.just("red", "white", "blue") .flatMap(carRepository::findByColor) .collect(Result::new, Result::add) .doOnNext(Result::stop) .subscribe(doWithResult);
A smarter Publisher ? Flux !
12
![Page 29: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/29.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Flux.just("red", "white", "blue") .flatMap(carRepository::findByColor) .collect(Result::new, Result::add) .doOnNext(Result::stop) .subscribe(doWithResult);
A smarter Publisher ? Flux !
12
interface CarRepository { Flux<Car> findByColor(String color);
}
![Page 30: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/30.jpg)
Mono
![Page 31: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/31.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Mono, push/pull CompletionStage
14
Mono.delayMillis(3000) .map(d -> "Spring 4") .or(Mono.delayMillis(2000).map(d -> "Spring 5")) .then(t -> Mono.just(t+ " world")) .elapsed() .block();
![Page 32: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/32.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Mono, push/pull CompletionStage
14
Mono.delayMillis(3000) .map(d -> "Spring 4") .or(Mono.delayMillis(2000).map(d -> "Spring 5")) .then(t -> Mono.just(t+ " world")) .elapsed() .block();
Non!
![Page 33: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/33.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Mono, push/pull CompletionStage
15
Mono.delayMillis(3000) .map(d -> "Spring 4") .or(Mono.delayMillis(2000).map(d -> "Spring 5")) .then(t -> Mono.just(t+ " world")) .elapsed() .subscribe();
![Page 34: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/34.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Mono, push/pull CompletionStage
15
Mono.delayMillis(3000) .map(d -> "Spring 4") .or(Mono.delayMillis(2000).map(d -> "Spring 5")) .then(t -> Mono.just(t+ " world")) .elapsed() .subscribe();
Oui!
![Page 35: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/35.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Non Blocking and RS types around
16
Type Semantic /Library Java 8 Reactive Streams /Java 9
RxJava1 (java6)
Reactor3 (java8)
RxJava2 (java6)
0 or 1 result CompletableFuture<T> Publisher<T> Observable<T> Mono<T> Maybe<T>
0 or N results Publisher<T> Observable<T> Flux<T> Observable<T>Flowable<T>
1 result CompletableFuture<T> Publisher<T> Single<T> Mono<T> Single<T>
No result CompletableFuture<Void> Publisher<Void> Completable Mono<Void> Completable
*Reactive Streams types are in bold**Akka Streams is also a notable RS implementor
![Page 36: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/36.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 / 17
3x Simpler API
![Page 37: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/37.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
ONE JAR reactor-core.jar
17
3x Simpler API
![Page 38: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/38.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
ONE JAR reactor-core.jar
17
3x Simpler API
![Page 39: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/39.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
ONE JAR reactor-core.jar
17
3x Simpler API Where Flux and Mono live
![Page 40: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/40.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
ONE JAR reactor-core.jar
17
3x Simpler API Where Flux and Mono live
Make task execution great again and FIFO
![Page 41: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/41.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Execution Model Freedom
18
Synchronous
Asynchronous
Scheduler / Scheduler.Worker
![Page 42: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/42.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Execution Model Freedom
19
Publisher Subscriber
![Page 43: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/43.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Execution Model Freedom
19
Publisher Subscriber
Thread: MAIN
Thread: MAIN
![Page 44: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/44.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Execution Model Freedom
20
Publisher Subscriber
+publishOn()Thread: Worker A
Thread: Worker A
![Page 45: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/45.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Execution Model Freedom
21
Publisher Subscriber
Thread: Worker B
+subscribeOn() Thread: Worker B
![Page 46: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/46.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Execution Model Freedom
22
Publisher Subscriber
+publishOn()Thread: Worker A
+subscribeOn() Thread: Worker B
![Page 47: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/47.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
3x more focus on Javadoc
23
http://projectreactor.io/core/docs/api
![Page 48: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/48.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Learning to Flux & Mono
24
![Page 49: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/49.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Learning to Flux & Mono
24
https://spring.io/blog/2016/06/07/notes-on-reactive-programming-part-i-the-reactive-
landscape
https://spring.io/blog/2016/06/13/notes-on-reactive-programming-part-ii-writing-some-code
https://spring.io/blog/2016/07/20/notes-on-reactive-programming-part-iii-a-simple-http-server-
application
![Page 50: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/50.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Learning to Flux & Mono
24
https://spring.io/blog/2016/06/07/notes-on-reactive-programming-part-i-the-reactive-
landscape
https://spring.io/blog/2016/06/13/notes-on-reactive-programming-part-ii-writing-some-code
https://spring.io/blog/2016/07/20/notes-on-reactive-programming-part-iii-a-simple-http-server-
application
Just browse spring.io/blog already
![Page 51: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/51.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Bridge Existing Asynchronous CodeMono<String> response = Mono.create(sink -> { HttpListener listener = event -> { if (event.getResponseCode() >= 400) { sink.error(new RuntimeExeption("Failed")); } else { String body = event.getBody(); if (body.isEmpty()) { sink.success(); } else { sink.success(body.toLowerCase()); } } }; client.addListener(listener); emitter.setCancellation(() -> client.removeListener(listener)); });
•
25
![Page 52: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/52.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Bridge Existing Asynchronous CodeMono<String> response = Mono.create(sink -> { HttpListener listener = event -> { if (event.getResponseCode() >= 400) { sink.error(new RuntimeExeption("Failed")); } else { String body = event.getBody(); if (body.isEmpty()) { sink.success(); } else { sink.success(body.toLowerCase()); } } }; client.addListener(listener); emitter.setCancellation(() -> client.removeListener(listener)); });
•
25
Also exists for Flux of N items
![Page 53: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/53.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Debug Mode
26
215 Hooks.onOperator(op -> op.operatorStacktrace()); 216 try { 217 Mono.just(1) 218 .map(d -> { 219 throw new RuntimeException(); 220 }) 221 .filter(d -> true) 222 .timestamp() 223 .elapsed() 224 .map(d -> d) 225 .block(); 226 } 227 catch(Exception e){ 228 e.printStackTrace(); 229 } 230 finally { 231 Hooks.resetOnOperator(); 232 }
![Page 54: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/54.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Debug Mode
26
215 Hooks.onOperator(op -> op.operatorStacktrace()); 216 try { 217 Mono.just(1) 218 .map(d -> { 219 throw new RuntimeException(); 220 }) 221 .filter(d -> true) 222 .timestamp() 223 .elapsed() 224 .map(d -> d) 225 .block(); 226 } 227 catch(Exception e){ 228 e.printStackTrace(); 229 } 230 finally { 231 Hooks.resetOnOperator(); 232 }
Capture stack for each operator declared after
![Page 55: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/55.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Debug Mode
26
215 Hooks.onOperator(op -> op.operatorStacktrace()); 216 try { 217 Mono.just(1) 218 .map(d -> { 219 throw new RuntimeException(); 220 }) 221 .filter(d -> true) 222 .timestamp() 223 .elapsed() 224 .map(d -> d) 225 .block(); 226 } 227 catch(Exception e){ 228 e.printStackTrace(); 229 } 230 finally { 231 Hooks.resetOnOperator(); 232 }
Capture stack for each operator declared after
Assembly trace from producer [reactor.core.publisher.MonoMapFuseable] :reactor.core.publisher.Mono.map(Mono.java:1795)reactor.HooksTest.testTrace2(HooksTest.java:218)
Composition chain until failing Operator :|_ Mono.map(HooksTest.java:218)|_ Mono.filter(HooksTest.java:221)|_ Mono.timestamp(HooksTest.java:222)|_ Mono.elapsed(HooksTest.java:223)|_ Mono.map(HooksTest.java:224)
![Page 56: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/56.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Create Gateways to Flux And Mono
27
EmitterProcessor<Integer> processor = EmitterProcessor.create(); int n = 100_000; processor.publishOn(Schedulers.single()) .subscribe(someService::handleData); BlockingSink<Integer> session = processor.connectSink(); for (int i = 0; i < n; i++) { while (!session.emit(i).isOk()) { if (session.hasFailed()) { throw session.getError(); }
//fake throttling Thread.sleep(1); } } session.finish();
•
EmitterProcessor
![Page 57: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/57.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Create Gateways to Flux And Mono
27
EmitterProcessor<Integer> processor = EmitterProcessor.create(); int n = 100_000; processor.publishOn(Schedulers.single()) .subscribe(someService::handleData); BlockingSink<Integer> session = processor.connectSink(); for (int i = 0; i < n; i++) { while (!session.emit(i).isOk()) { if (session.hasFailed()) { throw session.getError(); }
//fake throttling Thread.sleep(1); } } session.finish();
•
EmitterProcessor
Backpressure Companion
![Page 58: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/58.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
EmitterProcessor<Integer> processor = EmitterProcessor.create(); int n = 100_000; processor.publishOn(Schedulers.single()) .subscribe(someService::handleData); BlockingSink<Integer> session = processor.connectSink(); for (int i = 0; i < n; i++) { while (!session.emit(i).isOk()) { if (session.hasFailed()) { throw session.getError(); } Thread.sleep(1); //fake throttling } } session.finish();
•
Create Gateways to Flux And Mono
28
EmitterProcessor
![Page 59: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/59.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Operation Fusion
• Reactor has a mission to limit the overhead in stack and message passing
• 2 key categories : • “Macro Fusion” : merge operators in one (assembly time) • “Micro Fusion” : avoid queue creation and short circuit where
possible request lifecycle.
29
![Page 60: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/60.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Starve CPU’s with ParallelFlux…
30
Flux.range(1, 100000) .parallel(3) .runOn(Schedulers.parallel()) .collect(ArrayList::new, ArrayList::add) .sequential() .reduce(0, (a, b) -> a + b.size()) .subscribeWith(TestSubscriber.create()) .await(Duration.ofSeconds(5)) .assertValues(100_000) .assertNoError() .assertComplete();
•
![Page 61: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/61.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Starve CPU’s with ParallelFlux…
30
Flux.range(1, 100000) .parallel(3) .runOn(Schedulers.parallel()) .collect(ArrayList::new, ArrayList::add) .sequential() .reduce(0, (a, b) -> a + b.size()) .subscribeWith(TestSubscriber.create()) .await(Duration.ofSeconds(5)) .assertValues(100_000) .assertNoError() .assertComplete();
•
x3
![Page 62: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/62.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Efficient and micro bench ready
31
https://github.com/akarnokd/akarnokd-misc/tree/master/src/jmh/java/hu/akarnokd/comparison
![Page 63: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/63.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Efficient and micro bench ready
31
https://github.com/akarnokd/akarnokd-misc/tree/master/src/jmh/java/hu/akarnokd/comparison
![Page 64: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/64.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Efficient and micro bench ready
31
https://github.com/akarnokd/akarnokd-misc/tree/master/src/jmh/java/hu/akarnokd/comparison
![Page 65: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/65.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Bridge Fabulous RxJava
32
![Page 66: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/66.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Bridge Fabulous RxJava
32
RxJava1Adapter
![Page 67: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/67.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Bridge Java 9 Reactive Streams
33
![Page 68: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/68.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Bridge Java 9 Reactive Streams
33
JdkFlowAdapter
![Page 69: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/69.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Play with Reactor Core .NET
34
![Page 70: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/70.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Play with Reactor Core .NET
34
https://www.nuget.org/packages/Reactor.Core/
![Page 71: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/71.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Backpressure for JS: Reactor Core TypeScript
35
![Page 72: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/72.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Backpressure for JS: Reactor Core TypeScript
35
https://www.npmjs.com/package/reactor-core-js
![Page 73: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/73.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
EVERYTHING REACTIVE ?
36
![Page 74: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/74.jpg)
µ Service A
Data
Cloud
Messaging
Web
![Page 75: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/75.jpg)
Service B
MessageBroker
Datastore
20 ms
50 ms
150 ms
250 ms
20 ms
15 ms
3 ms
GATEWAY
µ Service A
![Page 76: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/76.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
Reactor Ecosystem roadmap
39
Reactor Netty
Reactor IPCSpring Framework
Spring 5, Spring Cloud Stream,
Spring Integration,Spring Data, Spring Boot, Spring Cloud,
Spring Security,…
Reactor Kafka
Extra add-ons dashboard, bus,
codecs, more operations & schedulers…
Reactor Redis
Reactor Aeron
![Page 77: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/77.jpg)
Spring Framework 5
![Page 78: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/78.jpg)
Spring Web MVC
@Controller, @RequestMapping
Servlet API
Servlet Container
![Page 79: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/79.jpg)
Spring Web MVC
@Controller, @RequestMapping
Servlet API
Servlet Container
Reactive
Non-blocking
…
![Page 80: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/80.jpg)
Spring Web MVC Spring Web Reactive
@Controller, @RequestMapping
Servlet API
Servlet Container
![Page 81: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/81.jpg)
Spring Web MVC Spring Web Reactive
@Controller, @RequestMapping
Servlet API
Servlet Container
Reactive HTTP
![Page 82: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/82.jpg)
Spring Web MVC Spring Web Reactive
@Controller, @RequestMapping
Servlet API
Servlet Container
Reactive HTTP
Servlet 3.1 Container
![Page 83: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/83.jpg)
Spring Web MVC Spring Web Reactive
@Controller, @RequestMapping
Servlet API
Servlet Container
Reactive HTTP
Servlet 3.1 ContainerServlet 3.1, Netty
![Page 84: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/84.jpg)
Spring Web MVC Spring Web Reactive
@Controller, @RequestMapping
Servlet API
Servlet Container
Reactive HTTP
Servlet 3.1 ContainerServlet 3.1, Netty, Undertow
![Page 85: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/85.jpg)
Non-Blocking HTTP GET
![Page 86: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/86.jpg)
Non-Blocking HTTP POST
![Page 87: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/87.jpg)
WebClient Scatter/Gather
![Page 88: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/88.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 / 51
SpringBootApplication@EnableBinding(Processor.class) public class WordCountApplication { @StreamListener @Output("output") public Flux<WordCount> countWords(@Input("input") Flux<String> words) { return words.window(ofSeconds(5), ofSeconds(1)) .flatMap(window -> window.groupBy(word -> word) .flatMap(group -> group.reduce(0, (counter, word) -> counter + 1) .map(count -> new WordCount(group.key(), count)))); } }
Spring Cloud Stream: Stateful processors
![Page 89: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/89.jpg)
Boot Data Cloud IntegrationSecurity
Reactive Efforts
![Page 90: Reactor 3.0, a reactive foundation for java 8 and Spring](https://reader031.fdocuments.us/reader031/viewer/2022022203/586fdb931a28ab18428b6179/html5/thumbnails/90.jpg)
Unless o therw ise ind ica ted , these s l ides are © 2013-2016 P ivo ta l So f tware , Inc . and l i censed under a Creat ive Commons At t r ibu t ion-NonCommerc ia l l i cense: h t tp : / / c rea t ivecommons.org / l i censes /by-nc /3 .0 /
@ProjectReactorhttp://github.com/reactorhttp://projectreactor.io
Extra Slideware:www.slideshare.net/SpringCentral/imperative-to-reactive-web-applicationswww.slideshare.net/SpringCentral/designing-implementing-and-using-reactive-apishttp://www.slideshare.net/RobHarrop/going-reactive-63425158