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

Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...MyIntelliSource, Inc.
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)OPEN KNOWLEDGE GmbH
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️anilsa9823
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...ICS
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...harshavardhanraghave
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about usDynamic Netsoft
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AIABDERRAOUF MEHENNI
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxbodapatigopi8531
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantAxelRicardoTrocheRiq
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...kellynguyen01
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfkalichargn70th171
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...soniya singh
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVshikhaohhpro
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationkaushalgiri8080
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfjoe51371421
 

Recently uploaded (20)

Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
Steps To Getting Up And Running Quickly With MyTimeClock Employee Scheduling ...
 
Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)Der Spagat zwischen BIAS und FAIRNESS (2024)
Der Spagat zwischen BIAS und FAIRNESS (2024)
 
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online  ☂️
CALL ON ➥8923113531 🔝Call Girls Kakori Lucknow best sexual service Online ☂️
 
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
The Real-World Challenges of Medical Device Cybersecurity- Mitigating Vulnera...
 
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
Reassessing the Bedrock of Clinical Function Models: An Examination of Large ...
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
DNT_Corporate presentation know about us
DNT_Corporate presentation know about usDNT_Corporate presentation know about us
DNT_Corporate presentation know about us
 
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AISyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
SyndBuddy AI 2k Review 2024: Revolutionizing Content Syndication with AI
 
Hand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptxHand gesture recognition PROJECT PPT.pptx
Hand gesture recognition PROJECT PPT.pptx
 
Salesforce Certified Field Service Consultant
Salesforce Certified Field Service ConsultantSalesforce Certified Field Service Consultant
Salesforce Certified Field Service Consultant
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
Short Story: Unveiling the Reasoning Abilities of Large Language Models by Ke...
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
Russian Call Girls in Karol Bagh Aasnvi ➡️ 8264348440 💋📞 Independent Escort S...
 
Optimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTVOptimizing AI for immediate response in Smart CCTV
Optimizing AI for immediate response in Smart CCTV
 
Exploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the ProcessExploring iOS App Development: Simplifying the Process
Exploring iOS App Development: Simplifying the Process
 
Project Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanationProject Based Learning (A.I).pptx detail explanation
Project Based Learning (A.I).pptx detail explanation
 
why an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdfwhy an Opensea Clone Script might be your perfect match.pdf
why an Opensea Clone Script might be your perfect match.pdf
 

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