SlideShare a Scribd company logo
1 of 45
Download to read offline
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

More Related Content

What's hot

What's hot (20)

I'm in ur browser, pwning your stuff - Attacking (with) Google Chrome Extensions
I'm in ur browser, pwning your stuff - Attacking (with) Google Chrome ExtensionsI'm in ur browser, pwning your stuff - Attacking (with) Google Chrome Extensions
I'm in ur browser, pwning your stuff - Attacking (with) Google Chrome Extensions
 
Networking in Java with NIO and Netty
Networking in Java with NIO and NettyNetworking in Java with NIO and Netty
Networking in Java with NIO and Netty
 
JUnit & Mockito, first steps
JUnit & Mockito, first stepsJUnit & Mockito, first steps
JUnit & Mockito, first steps
 
React + Redux Introduction
React + Redux IntroductionReact + Redux Introduction
React + Redux Introduction
 
Testing with JUnit 5 and Spring - Spring I/O 2022
Testing with JUnit 5 and Spring - Spring I/O 2022Testing with JUnit 5 and Spring - Spring I/O 2022
Testing with JUnit 5 and Spring - Spring I/O 2022
 
Angular and The Case for RxJS
Angular and The Case for RxJSAngular and The Case for RxJS
Angular and The Case for RxJS
 
Maven Introduction
Maven IntroductionMaven Introduction
Maven Introduction
 
Asynchronous API in Java8, how to use CompletableFuture
Asynchronous API in Java8, how to use CompletableFutureAsynchronous API in Java8, how to use CompletableFuture
Asynchronous API in Java8, how to use CompletableFuture
 
Exception handling
Exception handlingException handling
Exception handling
 
Introduction to RxJS
Introduction to RxJSIntroduction to RxJS
Introduction to RxJS
 
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
 
Functional Application Logging : Code Examples Using Spring Boot and Logback
Functional Application Logging : Code Examples Using Spring Boot and LogbackFunctional Application Logging : Code Examples Using Spring Boot and Logback
Functional Application Logging : Code Examples Using Spring Boot and Logback
 
Java 8 Lambda and Streams
Java 8 Lambda and StreamsJava 8 Lambda and Streams
Java 8 Lambda and Streams
 
Basics of Server Side Template Injection
Basics of Server Side Template InjectionBasics of Server Side Template Injection
Basics of Server Side Template Injection
 
Project Reactor By Example
Project Reactor By ExampleProject Reactor By Example
Project Reactor By Example
 
Java 8 Streams
Java 8 StreamsJava 8 Streams
Java 8 Streams
 
Unit Testing in Java
Unit Testing in JavaUnit Testing in Java
Unit Testing in Java
 
Exceptions handling notes in JAVA
Exceptions handling notes in JAVAExceptions handling notes in JAVA
Exceptions handling notes in JAVA
 
Building RESTful applications using Spring MVC
Building RESTful applications using Spring MVCBuilding RESTful applications using Spring MVC
Building RESTful applications using Spring MVC
 
Introduction to java 8 stream api
Introduction to java 8 stream apiIntroduction to java 8 stream api
Introduction to java 8 stream api
 

Viewers also liked

Viewers also liked (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 to rx-java-presentation

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

Similar to 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