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

Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
%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
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfproinshot.com
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfonteinmasabamasaba
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456KiaraTiradoMicha
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisamasabamasaba
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsAlberto González Trastoy
 
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
 
+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
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...Nitya salvi
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxalwaysnagaraju26
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfkalichargn70th171
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Steffen Staab
 
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
 

Recently uploaded (20)

Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
%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
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 
ManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide DeckManageIQ - Sprint 236 Review - Slide Deck
ManageIQ - Sprint 236 Review - Slide Deck
 
Exploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdfExploring the Best Video Editing App.pdf
Exploring the Best Video Editing App.pdf
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456LEVEL 5   - SESSION 1 2023 (1).pptx - PDF 123456
LEVEL 5 - SESSION 1 2023 (1).pptx - PDF 123456
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time ApplicationsUnveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
Unveiling the Tech Salsa of LAMs with Janus in Real-Time Applications
 
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...
 
+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...
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...Chinsurah Escorts ☎️8617697112  Starting From 5K to 15K High Profile Escorts ...
Chinsurah Escorts ☎️8617697112 Starting From 5K to 15K High Profile Escorts ...
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptxBUS PASS MANGEMENT SYSTEM USING PHP.pptx
BUS PASS MANGEMENT SYSTEM USING PHP.pptx
 
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdfPayment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
Payment Gateway Testing Simplified_ A Step-by-Step Guide for Beginners.pdf
 
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
Shapes for Sharing between Graph Data Spaces - and Epistemic Querying of RDF-...
 
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
 

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