SlideShare a Scribd company logo
1 of 32
Download to read offline
Panta rhei
by Tomasz Kowalczewski
Reactive Java in practice
EXAMPLES REPOSITORY
https://github.com/tkowalcz/rx-java-pantha-rhei
REACTIVE, ASYNCHRONOUS
People has been doing it for years
(Re)invented time and again by big companies
and/or in high performance products
Now every company may need to operate at
that scale
As users demand more and faster we need
tools to do it right
SYNCHRONOUS DESIGN
List<String> tweets = client.getNextTweets();
List<Tweet> validTweets = Lists.newArrayList();
for (String jsonTweet : tweets) {

Tweet tweet = gson.fromJson(jsonTweet, Tweet.class);
Image image;
image = download(tweet.getUser().getProfileImage());
Tweet.setImage(image);


if (tweet.isValidTweet()) {
validTweets.add(tweet);
}
}
DECOMPOSING INDIVIDUAL OPERATIONS
List<String> tweets = client.getNextTweets();
List<Tweet> validTweets = Lists.newArrayList();
for (String jsonTweet : tweets) {

Tweet tweet = gson.fromJson(jsonTweet, Tweet.class);
Image image;
image = download(tweet.getUser().getProfileImage());
Tweet.setImage(image);


if (tweet.isValidTweet()) {
validTweets.add(tweet);
}
}
DECOMPOSING INDIVIDUAL OPERATIONS
List<String> tweets = client.getNextTweets();
List<Tweet> validTweets = Lists.newArrayList();
for (String jsonTweet : tweets) {

Tweet tweet = gson.fromJson(jsonTweet, Tweet.class);
Image image;
image = download(tweet.getUser().getProfileImage());
Tweet.setImage(image);


if (tweet.isValidTweet()) {
validTweets.add(tweet);
}
}
DECOMPOSING INDIVIDUAL OPERATIONS
List<String> tweets = client.getNextTweets();
List<Tweet> validTweets = Lists.newArrayList();
for (String jsonTweet : tweets) {

Tweet tweet = gson.fromJson(jsonTweet, Tweet.class);
Image image;
image = download(tweet.getUser().getProfileImage());
Tweet.setImage(image);


if (tweet.isValidTweet()) {
validTweets.add(tweet);
}
}
DECOMPOSING INDIVIDUAL OPERATIONS
List<String> tweets = client.getNextTweets();
List<Tweet> validTweets = Lists.newArrayList();
for (String jsonTweet : tweets) {

Tweet tweet = gson.fromJson(jsonTweet, Tweet.class);
Image image;
image = download(tweet.getUser().getProfileImage());
Tweet.setImage(image);


if (tweet.isValidTweet()) {
validTweets.add(tweet);
}
}
DECOMPOSING INDIVIDUAL OPERATIONS
List<String> tweets = client.getNextTweets();
List<Tweet> validTweets = Lists.newArrayList();
for (String jsonTweet : tweets) {

Tweet tweet = gson.fromJson(jsonTweet, Tweet.class);
Image image;
image = download(tweet.getUser().getProfileImage());
Tweet.setImage(image);


if (tweet.isValidTweet()) {
validTweets.add(tweet);
}
}
WHAT IS MISSING?
List<String> tweets = client.getNextTweets();
List<Tweet> validTweets = Lists.newArrayList();
for (String jsonTweet : tweets) {

Tweet tweet = gson.fromJson(jsonTweet, Tweet.class);
Image image;
image = download(tweet.getUser().getProfileImage());
Tweet.setImage(image);


if (tweet.isValidTweet()) {
validTweets.add(tweet);
}
}
Error
handling
Timeouts
Monitoring
Logging
Back pressure
Parallelism
SYNCHRONOUS DESIGN
List<String> tweets = client.getNextTweets();
List<Tweet> validTweets = Lists.newArrayList();
for (String jsonTweet : tweets) {
Tweet tweet = gson.fromJson(jsonTweet, Tweet.class);
Image image;
image = download(tweet.getUser().getProfileImage());
Tweet.setImage(image);
if (tweet.isValidTweet()) {
validTweets.add(tweet);
}
}
WHAT IS MISSING?
List<String> tweets = client.getNextTweets();
List<Tweet> validTweets = Lists.newArrayList();
for (String jsonTweet : tweets) {

Tweet tweet = gson.fromJson(jsonTweet, Tweet.class);
Image image;
image = download(tweet.getUser().getProfileImage());
Tweet.setImage(image);


if (tweet.isValidTweet()) {
validTweets.add(tweet);
}
}
Error
handling
Timeouts
Monitoring
Logging
Back pressure
Parallelism
STREAMS (ELEMENTS + TIME)
[" ", " ", " ", " ", " "]
T1 T2 T3 T4 T5
SUBSCRIBE, MAP, FILTER
[" ", " ", " ", " ", " "]
subscribe
SUBSCRIBE, MAP, FILTER
[" ", " ", " ", " ", " "]
[ , , , , ]
map
subscribe
SUBSCRIBE, MAP, FILTER
[" ", " ", " ", " ", " "]
[ , , , , ]
[ , , ]
map
filter
subscribe
Reactive flow
t
subscribe
onNext*
onCompleted | onError
unsubscribe
just(1, 1, 2, 3, 5, 8, 13).filter(i -> i % 2 != 0)
// 1, 1, 3, 5, 13
just(1, 1, 2, 3, 5, 8, 13).map(i -> i * 2)
// 2, 2, 4, 6, 10, 16, 26
Exercise 1a: filter, map
Exercise 1b: take, error handling
Subscriptions flow
map
filter
source
…
subscribe
subscribe
subscribe
subscribe
subscribe onNext
onNext
onNext
onNext
subscribeOn
If subscription should be 

made on a different thread
observeOn
If notifications should be 

made on a different thread

(e.g. UI thread)
Exercise 2: Observable::create
just([1], [1], [2, 3], [5], [], [13])
.flatMap(arr -> just(arr))
// 1, 1, 2, 3, 5, 13
Exercise 3: basic flatMap
Exercise 4: flatMap & async
Exercise 5: error handling
Exercise 6: cache
Exercise 7: testing
Exercise 8a: subjects
?
Exercise 8a: subjects
Exercise 8b: combineLatest
Backpressure
AVAILABLE IN A LANGUAGE OR FRAMEWORK NEAR YOU
FURTHER READING
Examples from this presentation
https://github.com/tkowalcz/rx-java-pantha-rhei
Reactive Java project
https://github.com/Netflix/RxJava
Other reactive projects
http://reactivex.io/
http://rxmarbles.com/
http://davesexton.com/blog/post/To-Use-Subject-Or-
Not-To-Use-Subject.aspx
https://speakerdeck.com/dlew/reactive-extensions-
beyond-the-basics

More Related Content

Viewers also liked

эффект выпрямления сроков
эффект выпрямления сроковэффект выпрямления сроков
эффект выпрямления сроковMaxim Dorofeev
 
[4developers2016] - Taking advantage of microservice architecture and DynamoD...
[4developers2016] - Taking advantage of microservice architecture and DynamoD...[4developers2016] - Taking advantage of microservice architecture and DynamoD...
[4developers2016] - Taking advantage of microservice architecture and DynamoD...PROIDEA
 
Digipak analysis-Bon Iver, Bon Iver
Digipak analysis-Bon Iver, Bon Iver Digipak analysis-Bon Iver, Bon Iver
Digipak analysis-Bon Iver, Bon Iver mollygracethea
 
Knowledge organiztion
Knowledge organiztionKnowledge organiztion
Knowledge organiztionSahil Jain
 
Cotação de seguros online de veículos
Cotação  de  seguros online de veículos Cotação  de  seguros online de veículos
Cotação de seguros online de veículos Adriano Jacometo
 
Oficinas de Inverno
Oficinas de InvernoOficinas de Inverno
Oficinas de Invernoeditarfb
 
«От малых носимых устройств к построению больших софтверных экосистем и серви...
«От малых носимых устройств к построению больших софтверных экосистем и серви...«От малых носимых устройств к построению больших софтверных экосистем и серви...
«От малых носимых устройств к построению больших софтверных экосистем и серви...DataArt
 
Aprendizaje autonomo
Aprendizaje autonomoAprendizaje autonomo
Aprendizaje autonomoMajo_H
 
«Кроссплатформенная разработка мобильных приложений для бизнеса» Александр Еп...
«Кроссплатформенная разработка мобильных приложений для бизнеса» Александр Еп...«Кроссплатформенная разработка мобильных приложений для бизнеса» Александр Еп...
«Кроссплатформенная разработка мобильных приложений для бизнеса» Александр Еп...DataArt
 

Viewers also liked (13)

эффект выпрямления сроков
эффект выпрямления сроковэффект выпрямления сроков
эффект выпрямления сроков
 
[4developers2016] - Taking advantage of microservice architecture and DynamoD...
[4developers2016] - Taking advantage of microservice architecture and DynamoD...[4developers2016] - Taking advantage of microservice architecture and DynamoD...
[4developers2016] - Taking advantage of microservice architecture and DynamoD...
 
Digipak analysis-Bon Iver, Bon Iver
Digipak analysis-Bon Iver, Bon Iver Digipak analysis-Bon Iver, Bon Iver
Digipak analysis-Bon Iver, Bon Iver
 
Knowledge organiztion
Knowledge organiztionKnowledge organiztion
Knowledge organiztion
 
Cotação de seguros online de veículos
Cotação  de  seguros online de veículos Cotação  de  seguros online de veículos
Cotação de seguros online de veículos
 
Lisosomas y generalidades.
Lisosomas y generalidades.Lisosomas y generalidades.
Lisosomas y generalidades.
 
Project chater
Project chaterProject chater
Project chater
 
Premiere "Disney" Audition
Premiere "Disney" AuditionPremiere "Disney" Audition
Premiere "Disney" Audition
 
Oficinas de Inverno
Oficinas de InvernoOficinas de Inverno
Oficinas de Inverno
 
primera guerra
primera guerraprimera guerra
primera guerra
 
«От малых носимых устройств к построению больших софтверных экосистем и серви...
«От малых носимых устройств к построению больших софтверных экосистем и серви...«От малых носимых устройств к построению больших софтверных экосистем и серви...
«От малых носимых устройств к построению больших софтверных экосистем и серви...
 
Aprendizaje autonomo
Aprendizaje autonomoAprendizaje autonomo
Aprendizaje autonomo
 
«Кроссплатформенная разработка мобильных приложений для бизнеса» Александр Еп...
«Кроссплатформенная разработка мобильных приложений для бизнеса» Александр Еп...«Кроссплатформенная разработка мобильных приложений для бизнеса» Александр Еп...
«Кроссплатформенная разработка мобильных приложений для бизнеса» Александр Еп...
 

Similar to JDD2015: Panta rhei or Reactive Java in practice - Tomasz Kowalczewski

Deep dive reactive java (DevoxxPl)
Deep dive reactive java (DevoxxPl)Deep dive reactive java (DevoxxPl)
Deep dive reactive java (DevoxxPl)Tomasz Kowalczewski
 
Who needs MVVM? Architecture components & MVP - Timor Surkis, Colu
Who needs MVVM? Architecture components & MVP - Timor Surkis, ColuWho needs MVVM? Architecture components & MVP - Timor Surkis, Colu
Who needs MVVM? Architecture components & MVP - Timor Surkis, ColuDroidConTLV
 
Oleksandr Tolstykh
Oleksandr TolstykhOleksandr Tolstykh
Oleksandr TolstykhCodeFest
 
Creating a Facebook Clone - Part XXIX - Transcript.pdf
Creating a Facebook Clone - Part XXIX - Transcript.pdfCreating a Facebook Clone - Part XXIX - Transcript.pdf
Creating a Facebook Clone - Part XXIX - Transcript.pdfShaiAlmog1
 
Creating a Facebook Clone - Part XXXVIII - Transcript.pdf
Creating a Facebook Clone - Part XXXVIII - Transcript.pdfCreating a Facebook Clone - Part XXXVIII - Transcript.pdf
Creating a Facebook Clone - Part XXXVIII - Transcript.pdfShaiAlmog1
 
Dtsn devnest9
Dtsn devnest9Dtsn devnest9
Dtsn devnest9Angus Fox
 
SQLite 周りのテストをしよう
SQLite 周りのテストをしようSQLite 周りのテストをしよう
SQLite 周りのテストをしようussy
 
React Native - Workshop
React Native - WorkshopReact Native - Workshop
React Native - WorkshopFellipe Chagas
 
JSLab. Алексей Волков. "React на практике"
JSLab. Алексей Волков. "React на практике"JSLab. Алексей Волков. "React на практике"
JSLab. Алексей Волков. "React на практике"GeeksLab Odessa
 
Getting Started with Real-Time Analytics
Getting Started with Real-Time AnalyticsGetting Started with Real-Time Analytics
Getting Started with Real-Time AnalyticsAmazon Web Services
 
Big Data for each one of us
Big Data for each one of usBig Data for each one of us
Big Data for each one of usOSCON Byrum
 
Palestra - Utilizando tensorflow mobile e seus desafios
Palestra - Utilizando tensorflow mobile e seus desafiosPalestra - Utilizando tensorflow mobile e seus desafios
Palestra - Utilizando tensorflow mobile e seus desafiosGustavo Monteiro
 
Easy REST APIs with Jersey and RestyGWT
Easy REST APIs with Jersey and RestyGWTEasy REST APIs with Jersey and RestyGWT
Easy REST APIs with Jersey and RestyGWTDavid Chandler
 
React for Re-use: Creating UI Components with Confluence Connect
React for Re-use: Creating UI Components with Confluence ConnectReact for Re-use: Creating UI Components with Confluence Connect
React for Re-use: Creating UI Components with Confluence ConnectAtlassian
 

Similar to JDD2015: Panta rhei or Reactive Java in practice - Tomasz Kowalczewski (20)

Deep dive reactive java (DevoxxPl)
Deep dive reactive java (DevoxxPl)Deep dive reactive java (DevoxxPl)
Deep dive reactive java (DevoxxPl)
 
Who needs MVVM? Architecture components & MVP - Timor Surkis, Colu
Who needs MVVM? Architecture components & MVP - Timor Surkis, ColuWho needs MVVM? Architecture components & MVP - Timor Surkis, Colu
Who needs MVVM? Architecture components & MVP - Timor Surkis, Colu
 
Oleksandr Tolstykh
Oleksandr TolstykhOleksandr Tolstykh
Oleksandr Tolstykh
 
Appcelerator titanium
Appcelerator titaniumAppcelerator titanium
Appcelerator titanium
 
droidparts
droidpartsdroidparts
droidparts
 
Creating a Facebook Clone - Part XXIX - Transcript.pdf
Creating a Facebook Clone - Part XXIX - Transcript.pdfCreating a Facebook Clone - Part XXIX - Transcript.pdf
Creating a Facebook Clone - Part XXIX - Transcript.pdf
 
Creating a Facebook Clone - Part XXXVIII - Transcript.pdf
Creating a Facebook Clone - Part XXXVIII - Transcript.pdfCreating a Facebook Clone - Part XXXVIII - Transcript.pdf
Creating a Facebook Clone - Part XXXVIII - Transcript.pdf
 
Dtsn devnest9
Dtsn devnest9Dtsn devnest9
Dtsn devnest9
 
SQLite 周りのテストをしよう
SQLite 周りのテストをしようSQLite 周りのテストをしよう
SQLite 周りのテストをしよう
 
Android crashcourse
Android crashcourseAndroid crashcourse
Android crashcourse
 
React Native - Workshop
React Native - WorkshopReact Native - Workshop
React Native - Workshop
 
JSLab. Алексей Волков. "React на практике"
JSLab. Алексей Волков. "React на практике"JSLab. Алексей Волков. "React на практике"
JSLab. Алексей Волков. "React на практике"
 
Android Threading
Android ThreadingAndroid Threading
Android Threading
 
Getting Started with Real-Time Analytics
Getting Started with Real-Time AnalyticsGetting Started with Real-Time Analytics
Getting Started with Real-Time Analytics
 
Bar graph
Bar graphBar graph
Bar graph
 
Big Data for each one of us
Big Data for each one of usBig Data for each one of us
Big Data for each one of us
 
Palestra - Utilizando tensorflow mobile e seus desafios
Palestra - Utilizando tensorflow mobile e seus desafiosPalestra - Utilizando tensorflow mobile e seus desafios
Palestra - Utilizando tensorflow mobile e seus desafios
 
Finding Clojure
Finding ClojureFinding Clojure
Finding Clojure
 
Easy REST APIs with Jersey and RestyGWT
Easy REST APIs with Jersey and RestyGWTEasy REST APIs with Jersey and RestyGWT
Easy REST APIs with Jersey and RestyGWT
 
React for Re-use: Creating UI Components with Confluence Connect
React for Re-use: Creating UI Components with Confluence ConnectReact for Re-use: Creating UI Components with Confluence Connect
React for Re-use: Creating UI Components with Confluence Connect
 

Recently uploaded

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
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrainmasabamasaba
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...masabamasaba
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2
 
%+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
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension AidPhilip Schwarz
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park masabamasaba
 
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
 
%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
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrandmasabamasaba
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2
 
tonesoftg
tonesoftgtonesoftg
tonesoftglanshi9
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...panagenda
 
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
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in sowetomasabamasaba
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...masabamasaba
 

Recently uploaded (20)

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
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Knoxville Psychic Readings, Attraction spells,Br...
 
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital TransformationWSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
WSO2Con2024 - WSO2's IAM Vision: Identity-Led Digital Transformation
 
%+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...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
WSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go PlatformlessWSO2CON2024 - It's time to go Platformless
WSO2CON2024 - It's time to go Platformless
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park %in ivory park+277-882-255-28 abortion pills for sale in ivory park
%in ivory park+277-882-255-28 abortion pills for sale in ivory park
 
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
 
%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
 
%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand%in Midrand+277-882-255-28 abortion pills for sale in midrand
%in Midrand+277-882-255-28 abortion pills for sale in midrand
 
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
WSO2CON 2024 - Cloud Native Middleware: Domain-Driven Design, Cell-Based Arch...
 
tonesoftg
tonesoftgtonesoftg
tonesoftg
 
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
W01_panagenda_Navigating-the-Future-with-The-Hitchhikers-Guide-to-Notes-and-D...
 
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
 
%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto%in Soweto+277-882-255-28 abortion pills for sale in soweto
%in Soweto+277-882-255-28 abortion pills for sale in soweto
 
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
%+27788225528 love spells in Huntington Beach Psychic Readings, Attraction sp...
 

JDD2015: Panta rhei or Reactive Java in practice - Tomasz Kowalczewski

  • 1. Panta rhei by Tomasz Kowalczewski Reactive Java in practice
  • 3. REACTIVE, ASYNCHRONOUS People has been doing it for years (Re)invented time and again by big companies and/or in high performance products Now every company may need to operate at that scale As users demand more and faster we need tools to do it right
  • 4. SYNCHRONOUS DESIGN List<String> tweets = client.getNextTweets(); List<Tweet> validTweets = Lists.newArrayList(); for (String jsonTweet : tweets) {
 Tweet tweet = gson.fromJson(jsonTweet, Tweet.class); Image image; image = download(tweet.getUser().getProfileImage()); Tweet.setImage(image); 
 if (tweet.isValidTweet()) { validTweets.add(tweet); } }
  • 5. DECOMPOSING INDIVIDUAL OPERATIONS List<String> tweets = client.getNextTweets(); List<Tweet> validTweets = Lists.newArrayList(); for (String jsonTweet : tweets) {
 Tweet tweet = gson.fromJson(jsonTweet, Tweet.class); Image image; image = download(tweet.getUser().getProfileImage()); Tweet.setImage(image); 
 if (tweet.isValidTweet()) { validTweets.add(tweet); } }
  • 6. DECOMPOSING INDIVIDUAL OPERATIONS List<String> tweets = client.getNextTweets(); List<Tweet> validTweets = Lists.newArrayList(); for (String jsonTweet : tweets) {
 Tweet tweet = gson.fromJson(jsonTweet, Tweet.class); Image image; image = download(tweet.getUser().getProfileImage()); Tweet.setImage(image); 
 if (tweet.isValidTweet()) { validTweets.add(tweet); } }
  • 7. DECOMPOSING INDIVIDUAL OPERATIONS List<String> tweets = client.getNextTweets(); List<Tweet> validTweets = Lists.newArrayList(); for (String jsonTweet : tweets) {
 Tweet tweet = gson.fromJson(jsonTweet, Tweet.class); Image image; image = download(tweet.getUser().getProfileImage()); Tweet.setImage(image); 
 if (tweet.isValidTweet()) { validTweets.add(tweet); } }
  • 8. DECOMPOSING INDIVIDUAL OPERATIONS List<String> tweets = client.getNextTweets(); List<Tweet> validTweets = Lists.newArrayList(); for (String jsonTweet : tweets) {
 Tweet tweet = gson.fromJson(jsonTweet, Tweet.class); Image image; image = download(tweet.getUser().getProfileImage()); Tweet.setImage(image); 
 if (tweet.isValidTweet()) { validTweets.add(tweet); } }
  • 9. DECOMPOSING INDIVIDUAL OPERATIONS List<String> tweets = client.getNextTweets(); List<Tweet> validTweets = Lists.newArrayList(); for (String jsonTweet : tweets) {
 Tweet tweet = gson.fromJson(jsonTweet, Tweet.class); Image image; image = download(tweet.getUser().getProfileImage()); Tweet.setImage(image); 
 if (tweet.isValidTweet()) { validTweets.add(tweet); } }
  • 10. WHAT IS MISSING? List<String> tweets = client.getNextTweets(); List<Tweet> validTweets = Lists.newArrayList(); for (String jsonTweet : tweets) {
 Tweet tweet = gson.fromJson(jsonTweet, Tweet.class); Image image; image = download(tweet.getUser().getProfileImage()); Tweet.setImage(image); 
 if (tweet.isValidTweet()) { validTweets.add(tweet); } } Error handling Timeouts Monitoring Logging Back pressure Parallelism
  • 11. SYNCHRONOUS DESIGN List<String> tweets = client.getNextTweets(); List<Tweet> validTweets = Lists.newArrayList(); for (String jsonTweet : tweets) { Tweet tweet = gson.fromJson(jsonTweet, Tweet.class); Image image; image = download(tweet.getUser().getProfileImage()); Tweet.setImage(image); if (tweet.isValidTweet()) { validTweets.add(tweet); } }
  • 12. WHAT IS MISSING? List<String> tweets = client.getNextTweets(); List<Tweet> validTweets = Lists.newArrayList(); for (String jsonTweet : tweets) {
 Tweet tweet = gson.fromJson(jsonTweet, Tweet.class); Image image; image = download(tweet.getUser().getProfileImage()); Tweet.setImage(image); 
 if (tweet.isValidTweet()) { validTweets.add(tweet); } } Error handling Timeouts Monitoring Logging Back pressure Parallelism
  • 13. STREAMS (ELEMENTS + TIME) [" ", " ", " ", " ", " "] T1 T2 T3 T4 T5
  • 14. SUBSCRIBE, MAP, FILTER [" ", " ", " ", " ", " "] subscribe
  • 15. SUBSCRIBE, MAP, FILTER [" ", " ", " ", " ", " "] [ , , , , ] map subscribe
  • 16. SUBSCRIBE, MAP, FILTER [" ", " ", " ", " ", " "] [ , , , , ] [ , , ] map filter subscribe
  • 18. just(1, 1, 2, 3, 5, 8, 13).filter(i -> i % 2 != 0) // 1, 1, 3, 5, 13 just(1, 1, 2, 3, 5, 8, 13).map(i -> i * 2) // 2, 2, 4, 6, 10, 16, 26 Exercise 1a: filter, map
  • 19. Exercise 1b: take, error handling
  • 20. Subscriptions flow map filter source … subscribe subscribe subscribe subscribe subscribe onNext onNext onNext onNext subscribeOn If subscription should be made on a different thread observeOn If notifications should be made on a different thread (e.g. UI thread)
  • 22. just([1], [1], [2, 3], [5], [], [13]) .flatMap(arr -> just(arr)) // 1, 1, 2, 3, 5, 13 Exercise 3: basic flatMap
  • 24. Exercise 5: error handling
  • 31. AVAILABLE IN A LANGUAGE OR FRAMEWORK NEAR YOU
  • 32. FURTHER READING Examples from this presentation https://github.com/tkowalcz/rx-java-pantha-rhei Reactive Java project https://github.com/Netflix/RxJava Other reactive projects http://reactivex.io/ http://rxmarbles.com/ http://davesexton.com/blog/post/To-Use-Subject-Or- Not-To-Use-Subject.aspx https://speakerdeck.com/dlew/reactive-extensions- beyond-the-basics