SlideShare una empresa de Scribd logo
1 de 45
Descargar para leer sin conexión
RX JAVA
MATEUSZ BUKOWICZ
REACTIVEX
REACTIVE SUPPORT IN DIFFERENT LANGUAGES
REACTIVE EXTENSIONS
▸ Rx.Net
▸ RxJava
▸ RxJS
▸ RxScala
▸ RxClojure
▸ RxCpp
▸ Rx.rb
▸ RxPY
▸ RxGroovy
▸ RxJRuby
▸ RxKotlin
▸ RxSwift
HOW IT BEGAN
RX.NET
▸ Rx.NET released in 2009
▸ Shipped with .NET 4.0 (2010)
AN API FOR ASYNCHRONOUS
PROGRAMMING WITH
OBSERVABLE STREAMS.
reactivex.io
DEFINITION
OBSERVER AGAIN
OBSERVER PATTERN
https://en.wikipedia.org/wiki/Observer_pattern
Observable
WHAT IS REACTIVE?
REACTIVE MANIFESTO
▸ responsive
▸ resilient
▸ elastic
▸ message-driven
REACTIVE CAN BE REPULSIVE
REACTIVE MANIFESTO CONTROVERSY
REACTIVE AS A LIFESTYLE
REACTIVE PROGRAMMING
OLD WAY OF DOING THINGS
PROCEDURAL WAY
FROM PROCEDURAL TO FUNCTIONAL
FUNCTIONAL WAY
FROM FUNCTIONAL TO REACTIVE
REACTIVE WAY
HOW TO OBSERVE?
ITERABLE VS OBSERVABLE
http://reactivex.io/intro.html
OBSERVER OBSERVES
OBSERVER USAGE
OPERATORS - FILTER
FILTER
http://rxmarbles.com/#filter
OPERATORS - TAKE
TAKE
http://rxmarbles.com/#take
OPERATORS - ZIP
ZIP
http://rxmarbles.com/#zip
WHICH OPERATORS SHOULD I USE?
OPERATORS DECISION TREE
http://reactivex.io/documentation/operators.html#tree
NETFLIX OLD WAY - PROBLEM
http://techblog.netflix.com/2012/07/embracing-differences-inside-netflix.html
NETFLIX OLD WAY - PROBLEM
http://techblog.netflix.com/2012/07/embracing-differences-inside-netflix.html
NETFLIX OLD WAY - PROBLEM
http://techblog.netflix.com/2013/01/optimizing-netflix-api.html
NETFLIX NEW WAY - SOLUTION
http://techblog.netflix.com/2013/01/optimizing-netflix-api.html
THINK ABOUT THE FUTURE
single item multiple items
sync T getData() Iterable<T> getData()
async Future<T> getData() ?
List<Future<T>> getData()
A NEW GUY COMES IN
RX.NET IS SO COOL
OBSERVABLE TO THE RESCUE
single item multiple items
sync T getData() Iterable<T> getData()
async Future<T> getData()
Observable<T>
getData()
NETFLIX NEW WAY - SOLUTION
http://techblog.netflix.com/2012/07/embracing-differences-inside-netflix.html
NETFLIX NEW WAY - SOLUTION
http://techblog.netflix.com/2012/07/embracing-differences-inside-netflix.html
http://techblog.netflix.com/2013/02/rxjava-netflix-api.html
PARALLEL WORK
CONCURRENCY
▸ most operators - synchronous by default
▸ some operators - implicit concurrency
▸ programmatic concurrency: observeOn/subscribeOn
http://reactivex.io/documentation/scheduler.html
can be anywhere
RX.JAVA SCHEDULERS
SCHEDULERS
http://reactivex.io/documentation/scheduler.html
SCHEDULERS IN ACTION
REACTIVE ANDROID
RX ANDROID
ERROR HANDLING
ON ERROR RESUME NEXT
http://reactivex.io/documentation/operators/catch.html
OH, MY BACK!
BACK PRESSURE
BACKPRESSURE-RELATED OPERATORS
BUFFER OPERATOR
https://github.com/ReactiveX/RxJava/wiki/Backpressure
BACK PRESSURE
ON BACKPRESSURE BUFFER
https://github.com/ReactiveX/RxJava/wiki/Backpressure
MORE RESILIENT RX.JAVA
HYSTRIX + RX.JAVA
https://github.com/Netflix/Hystrix/wiki/How-To-Use#Reactive-Execution
CIRCUIT BREAKER
CLOSED
OPENHALF-OPEN
failure threshold
reached
timeout timer
expired
operation failed
success count
threshold reached
always
return
failure
increment failure
counter on failure
increment
success
counter on
success
start
REACTIVE NETTY
RX NETTY
https://github.com/Netflix-Skunkworks/WSPerfLab/blob/master/test-results/RxNetty_vs_Tomcat_April2015.pdf
CPU saturated
clients
req/s avg lat [ms]
RX NETTY VS TOMCAT
WHY RX NETTY IS BETTER?
▸ lower CPU consumption
▸ lower object allocation rate/less GC
▸ event loop architecture vs thread pool architecture
▸ no thread pool locks
▸ less thread migrations
▸ more CPU Instructions Per Cycle (IPC)
https://github.com/Netflix-Skunkworks/WSPerfLab/blob/master/test-results/RxNetty_vs_Tomcat_April2015.pdf
REACTIVE STREAMS - INITIATIVE
http://www.reactive-streams.org
REACTIVE STREAMS - SCOPE
http://www.reactive-streams.org
FUTURE IS REACTIVE
JAVA 9 FLOW API
▸ JDK 9.0
▸ RxJava 2.x -> Reactive Streams implementation
▸ JPA -> Hibernate
▸ Reactive Streams -> RxJava 2.x
THE END

Más contenido relacionado

La actualidad más candente

Learn REST API with Python
Learn REST API with PythonLearn REST API with Python
Learn REST API with Python
Larry Cai
 

La actualidad más candente (20)

Spring Webflux
Spring WebfluxSpring Webflux
Spring Webflux
 
Intro to Reactive Programming
Intro to Reactive ProgrammingIntro to Reactive Programming
Intro to Reactive Programming
 
Spring Boot
Spring BootSpring Boot
Spring Boot
 
Project Reactor Now and Tomorrow
Project Reactor Now and TomorrowProject Reactor Now and Tomorrow
Project Reactor Now and Tomorrow
 
Angular & RXJS: examples and use cases
Angular & RXJS: examples and use casesAngular & RXJS: examples and use cases
Angular & RXJS: examples and use cases
 
Spring boot jpa
Spring boot jpaSpring boot jpa
Spring boot jpa
 
Spring Framework - AOP
Spring Framework - AOPSpring Framework - AOP
Spring Framework - AOP
 
(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines(Declarative) Jenkins Pipelines
(Declarative) Jenkins Pipelines
 
Writing a fast HTTP parser
Writing a fast HTTP parserWriting a fast HTTP parser
Writing a fast HTTP parser
 
React hooks
React hooksReact hooks
React hooks
 
Introducción a Wiremock
Introducción a WiremockIntroducción a Wiremock
Introducción a Wiremock
 
Reactive programming intro
Reactive programming introReactive programming intro
Reactive programming intro
 
ZgPHP 97 - Microservice architecture in Laravel
ZgPHP 97 - Microservice architecture in LaravelZgPHP 97 - Microservice architecture in Laravel
ZgPHP 97 - Microservice architecture in Laravel
 
WebAssembly Overview
WebAssembly OverviewWebAssembly Overview
WebAssembly Overview
 
Spring I/O 2012: Natural Templating in Spring MVC with Thymeleaf
Spring I/O 2012: Natural Templating in Spring MVC with ThymeleafSpring I/O 2012: Natural Templating in Spring MVC with Thymeleaf
Spring I/O 2012: Natural Templating in Spring MVC with Thymeleaf
 
GraalVM: Run Programs Faster Everywhere
GraalVM: Run Programs Faster EverywhereGraalVM: Run Programs Faster Everywhere
GraalVM: Run Programs Faster Everywhere
 
Learn REST API with Python
Learn REST API with PythonLearn REST API with Python
Learn REST API with Python
 
gRPC: The Story of Microservices at Square
gRPC: The Story of Microservices at SquaregRPC: The Story of Microservices at Square
gRPC: The Story of Microservices at Square
 
React hooks
React hooksReact hooks
React hooks
 
Intro to React
Intro to ReactIntro to React
Intro to React
 

Destacado

Destacado (12)

Reactive Programming on Android - RxAndroid - RxJava
Reactive Programming on Android - RxAndroid - RxJavaReactive Programming on Android - RxAndroid - RxJava
Reactive Programming on Android - RxAndroid - RxJava
 
Introduction to Reactive Java
Introduction to Reactive JavaIntroduction to Reactive Java
Introduction to Reactive Java
 
Reactive in Android and Beyond Rx
Reactive in Android and Beyond RxReactive in Android and Beyond Rx
Reactive in Android and Beyond Rx
 
Sword fighting with Dagger GDG-NYC Jan 2016
 Sword fighting with Dagger GDG-NYC Jan 2016 Sword fighting with Dagger GDG-NYC Jan 2016
Sword fighting with Dagger GDG-NYC Jan 2016
 
Intro to Functional Programming with RxJava
Intro to Functional Programming with RxJavaIntro to Functional Programming with RxJava
Intro to Functional Programming with RxJava
 
Practical RxJava for Android
Practical RxJava for AndroidPractical RxJava for Android
Practical RxJava for Android
 
Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJava
 
Supercharged java 8 : with cyclops-react
Supercharged java 8 : with cyclops-reactSupercharged java 8 : with cyclops-react
Supercharged java 8 : with cyclops-react
 
Rx Presentation for Adults
Rx Presentation for AdultsRx Presentation for Adults
Rx Presentation for Adults
 
Exception log practical_coding_guide, 예외와 로그 코딩 실용 가이드
Exception log practical_coding_guide, 예외와 로그 코딩 실용 가이드Exception log practical_coding_guide, 예외와 로그 코딩 실용 가이드
Exception log practical_coding_guide, 예외와 로그 코딩 실용 가이드
 
Java 8 Stream API and RxJava Comparison
Java 8 Stream API and RxJava ComparisonJava 8 Stream API and RxJava Comparison
Java 8 Stream API and RxJava Comparison
 
코딩소림사 Rx java
코딩소림사 Rx java코딩소림사 Rx java
코딩소림사 Rx java
 

Similar a rx-java-presentation

Functional Web Development
Functional Web DevelopmentFunctional Web Development
Functional Web Development
FITC
 

Similar a rx-java-presentation (20)

Reactive Spring Framework 5
Reactive Spring Framework 5Reactive Spring Framework 5
Reactive Spring Framework 5
 
Cycle.js a reactive framework
Cycle.js  a reactive frameworkCycle.js  a reactive framework
Cycle.js a reactive framework
 
Rx Swift
Rx SwiftRx Swift
Rx Swift
 
Reactive microservices with eclipse vert.x
Reactive microservices with eclipse vert.xReactive microservices with eclipse vert.x
Reactive microservices with eclipse vert.x
 
Serverless forwardjs
Serverless forwardjsServerless forwardjs
Serverless forwardjs
 
Functional Web Development
Functional Web DevelopmentFunctional Web Development
Functional Web Development
 
[JOI] TOTVS Developers Joinville - Java #1
[JOI] TOTVS Developers Joinville - Java #1[JOI] TOTVS Developers Joinville - Java #1
[JOI] TOTVS Developers Joinville - Java #1
 
A React Journey
A React JourneyA React Journey
A React Journey
 
BASICS OF VERT.X - A toolkit for building asynchronous and reactive app
BASICS OF VERT.X - A toolkit for building asynchronous and reactive appBASICS OF VERT.X - A toolkit for building asynchronous and reactive app
BASICS OF VERT.X - A toolkit for building asynchronous and reactive app
 
IPT High Performance Reactive Java BGOUG 2016
IPT High Performance Reactive Java BGOUG 2016IPT High Performance Reactive Java BGOUG 2016
IPT High Performance Reactive Java BGOUG 2016
 
Intro to RxJS
Intro to RxJSIntro to RxJS
Intro to RxJS
 
NGRX Apps in Depth
NGRX Apps in DepthNGRX Apps in Depth
NGRX Apps in Depth
 
How (not) to use reactive streams in java 9+
How (not) to use reactive streams in java 9+How (not) to use reactive streams in java 9+
How (not) to use reactive streams in java 9+
 
Reactive java programming for the impatient
Reactive java programming for the impatientReactive java programming for the impatient
Reactive java programming for the impatient
 
Java Stammtisch Würzburg - CONAIR
Java Stammtisch Würzburg - CONAIRJava Stammtisch Würzburg - CONAIR
Java Stammtisch Würzburg - CONAIR
 
Mvvm is like born fraction
Mvvm is like born fractionMvvm is like born fraction
Mvvm is like born fraction
 
React native.key
React native.keyReact native.key
React native.key
 
Meetup 2022 - APIs with Quarkus.pdf
Meetup 2022 - APIs with Quarkus.pdfMeetup 2022 - APIs with Quarkus.pdf
Meetup 2022 - APIs with Quarkus.pdf
 
Reactive Microservice And Spring5
Reactive Microservice And Spring5Reactive Microservice And Spring5
Reactive Microservice And Spring5
 
R Apache
R ApacheR Apache
R Apache
 

rx-java-presentation