SlideShare a Scribd company logo
© 2022 Thoughtworks | Confidential
Reactive Programming
Mritunjay Dubey & Kumar Sankara Iyer
© 2022 Thoughtworks | Confidential
Table of contents
Setup 03
Threading models and Demo 04
Reactive programming concepts and Spring Webflux 05
Reactive Data types & Operators and hands-on 06
Corner cases, Error handling and hands-on 07
Reactor context demo 10
Demo of end-to-end streams 13
Miscellaneous topics 17
2
© 2022 Thoughtworks | Confidential
Setup
3
© 2022 Thoughtworks | Confidential
Prerequisites for hands-on
1. Install Java 17 (preferred)
2. Use an IDE like Intellij
3. Install Git (good to have)
4. Install Postman (good to have)
5. Clone the code from
https://github.com/reactive-workshop/reactive-building-blocks
6. Run ./gradlew bootRun
7. Import Reactive-Workshop.postman_collectioninto Postman and run the first
API “Get User By User Id”
4
© 2022 Thoughtworks | Confidential
Threading models
5
© 2022 Thoughtworks | Confidential
Thread-per-request model
6
© 2022 Thoughtworks | Confidential
Drawbacks of the
thread-per-request
model
The thread-per-request model is
neither performant not scalable
Context
switching is
expensive
Threads are
blocked while
I/O is in progress
7
A thread takes a
minimum of 1 MB
of stack size
Threads
increase as the
number of
requests
© 2022 Thoughtworks | Confidential
Event-loop model
8
© 2022 Thoughtworks | Confidential
Netty
9
A framework to create asynchronous, event-driven applications
© 2022 Thoughtworks | Confidential
Demo on threading models
10
© 2022 Thoughtworks | Confidential
Reactive programming concepts and Spring
Webflux
11
© 2022 Thoughtworks | Confidential 12
Asynchronous
1.
Reactive streams
There are several implementations of the Reactive streams specification - RxJava,
Reactor, Akka streams, RxJavaScript and so on
A standard for asynchronous stream processing
Non-blocking
2.
Backpressure
3.
12
© 2022 Thoughtworks
© 2022 Thoughtworks | Confidential
Reactive streams - some keywords
13
© 2022 Thoughtworks | Confidential
Spring Webflux
14
A fully Reactive framework that embraces Functional Reactive Programming
© 2022 Thoughtworks | Confidential
Reactive Data
types & Operators
15
© 2022 Thoughtworks | Confidential
Mono
Mono is a Reactive Streams Publisher that emits at most one item and then terminates
16
16
For eg;
© 2022 Thoughtworks | Confidential
Flux
Flux is a Reactive Streams Publisher that emits 0 to N elements and then completes
17
17
For eg;
© 2022 Thoughtworks | Confidential
map
18
18
© 2022 Thoughtworks
Transforms a Flux to another
Flux by applying a
synchronous function to
each item
© 2022 Thoughtworks | Confidential
flatMap
19
19
© 2022 Thoughtworks
Flatten the inner publishers
into a single Flux through
merging, allowing them to
interleave
© 2022 Thoughtworks | Confidential
filter
20
20
© 2022 Thoughtworks
Evaluate each source value
against the given predicate
© 2022 Thoughtworks | Confidential
zip
21
21
© 2022 Thoughtworks
Wait for all sources to emit
one element, then combine
these elements. Continue till
any of the sources complete
© 2022 Thoughtworks | Confidential
Hands-on with
Reactor operators
22
© 2022 Thoughtworks | Confidential
Corner cases and
Error handling
23
© 2022 Thoughtworks | Confidential
switchIfEmpty
24
24
© 2022 Thoughtworks
Switch to an alternative
publisher if this publisher is
empty
© 2022 Thoughtworks | Confidential
onErrorMap
25
25
© 2022 Thoughtworks
Transform a source error to
another error
© 2022 Thoughtworks | Confidential
onErrorResume
26
26
© 2022 Thoughtworks
Subscribe to a fallback
publisher if any error
happens in source
© 2022 Thoughtworks | Confidential
Hands-on with
error handling
27
© 2022 Thoughtworks | Confidential
Reactor context - a demo
28
© 2022 Thoughtworks | Confidential
End-to-end streams - a demo
29
© 2022 Thoughtworks | Confidential
Miscellaneous
30
© 2022 Thoughtworks | Confidential
Reactive
programming is fun!
Building and running on reactive
applications on production requires
Further reading
Learning curve
31
Blocking calls
A word on
Testing
© 2022 Thoughtworks | Confidential
Discussion
32
© 2022 Thoughtworks | Confidential
Thankyou
33

More Related Content

What's hot

Konsep Fungsi
Konsep FungsiKonsep Fungsi
Konsep Fungsi
Reza Ferial Ashadi
 
Rpp pangkat nol dan pangkat bulat negatif
Rpp pangkat nol dan pangkat bulat negatifRpp pangkat nol dan pangkat bulat negatif
Rpp pangkat nol dan pangkat bulat negatif
rizkynurulfatihahzone
 
FPGA Board (Nexys A7-100T) User Guide.pdf
FPGA Board (Nexys A7-100T) User Guide.pdfFPGA Board (Nexys A7-100T) User Guide.pdf
FPGA Board (Nexys A7-100T) User Guide.pdf
ssuser6a66ac2
 
Silabus Matematika Wajib Kelas XI
Silabus Matematika Wajib Kelas XISilabus Matematika Wajib Kelas XI
Silabus Matematika Wajib Kelas XI
Muhammad Alfiansyah Alfi
 
1. konsep bilangan berpangkat, bentuk akar dan logaritma
1.    konsep bilangan berpangkat, bentuk akar dan logaritma1.    konsep bilangan berpangkat, bentuk akar dan logaritma
1. konsep bilangan berpangkat, bentuk akar dan logaritma
darmawati20
 
Intalasi OJS 3.x Pada CPANEL (Fresh Install)
Intalasi OJS 3.x Pada CPANEL (Fresh Install)Intalasi OJS 3.x Pada CPANEL (Fresh Install)
Intalasi OJS 3.x Pada CPANEL (Fresh Install)
Relawan Jurnal Indonesia
 
Handout kd 2.3 (tugas mid)
Handout kd 2.3 (tugas mid)Handout kd 2.3 (tugas mid)
Handout kd 2.3 (tugas mid)
Novita Tiannata
 
Alat Peraga "BLAJAR" alias Blok Aljabar
Alat Peraga "BLAJAR" alias Blok AljabarAlat Peraga "BLAJAR" alias Blok Aljabar
Alat Peraga "BLAJAR" alias Blok Aljabar
Nadia Hasan
 
ALUR TUJUAN PEMBELAJARAN MATEMATIKA KELAS VII
ALUR TUJUAN PEMBELAJARAN MATEMATIKA KELAS VIIALUR TUJUAN PEMBELAJARAN MATEMATIKA KELAS VII
ALUR TUJUAN PEMBELAJARAN MATEMATIKA KELAS VII
filzasabila40
 
UMLtoNoSQL : From UML domain models to NoSQL Databases
UMLtoNoSQL : From UML domain models to NoSQL DatabasesUMLtoNoSQL : From UML domain models to NoSQL Databases
UMLtoNoSQL : From UML domain models to NoSQL Databases
Jordi Cabot
 
24.algoritma knapsack
24.algoritma knapsack24.algoritma knapsack
24.algoritma knapsack
Universitas Bina Darma Palembang
 
LIMIT FUNGSI (RPP & LKPD)
LIMIT FUNGSI (RPP & LKPD)LIMIT FUNGSI (RPP & LKPD)
LIMIT FUNGSI (RPP & LKPD)
Muhammad Alfiansyah Alfi
 
Jaminan Kualitas Perangkat Lunak
Jaminan Kualitas Perangkat LunakJaminan Kualitas Perangkat Lunak
Jaminan Kualitas Perangkat Lunak
Yunita Rainbow
 
RPP Kelas X Materi Eksponen - Kurikulum 2013
RPP Kelas X Materi Eksponen - Kurikulum 2013RPP Kelas X Materi Eksponen - Kurikulum 2013
RPP Kelas X Materi Eksponen - Kurikulum 2013
Rahma Siska Utari
 
DETERMINAN DAN INVERS MATRIKS 22.ppt
DETERMINAN DAN INVERS MATRIKS 22.pptDETERMINAN DAN INVERS MATRIKS 22.ppt
DETERMINAN DAN INVERS MATRIKS 22.ppt
AhmadOfficial4
 
Buku Siswa Barisan dan Deret
Buku Siswa Barisan dan DeretBuku Siswa Barisan dan Deret
Buku Siswa Barisan dan Deret
arvinefriani
 
Modul Ajar Matematika Kelas 5 Fase C Kurikulum Merdeka [abdiera.com]
Modul Ajar Matematika Kelas 5 Fase C Kurikulum Merdeka [abdiera.com]Modul Ajar Matematika Kelas 5 Fase C Kurikulum Merdeka [abdiera.com]
Modul Ajar Matematika Kelas 5 Fase C Kurikulum Merdeka [abdiera.com]
Fathan Emran
 
RPP - Simpangan Kuartil
RPP - Simpangan KuartilRPP - Simpangan Kuartil
RPP - Simpangan Kuartil
matematikauntirta
 
Modul Ajar Persamaan Garis Lurus fix.pdf
Modul Ajar Persamaan Garis Lurus fix.pdfModul Ajar Persamaan Garis Lurus fix.pdf
Modul Ajar Persamaan Garis Lurus fix.pdf
IstiyaniIstiyani
 
Bab iii 5. memahami cara menyederhanakan bentuk aljabar
Bab iii   5. memahami cara menyederhanakan bentuk aljabarBab iii   5. memahami cara menyederhanakan bentuk aljabar
Bab iii 5. memahami cara menyederhanakan bentuk aljabar
Muhammad Alfiansyah Alfi
 

What's hot (20)

Konsep Fungsi
Konsep FungsiKonsep Fungsi
Konsep Fungsi
 
Rpp pangkat nol dan pangkat bulat negatif
Rpp pangkat nol dan pangkat bulat negatifRpp pangkat nol dan pangkat bulat negatif
Rpp pangkat nol dan pangkat bulat negatif
 
FPGA Board (Nexys A7-100T) User Guide.pdf
FPGA Board (Nexys A7-100T) User Guide.pdfFPGA Board (Nexys A7-100T) User Guide.pdf
FPGA Board (Nexys A7-100T) User Guide.pdf
 
Silabus Matematika Wajib Kelas XI
Silabus Matematika Wajib Kelas XISilabus Matematika Wajib Kelas XI
Silabus Matematika Wajib Kelas XI
 
1. konsep bilangan berpangkat, bentuk akar dan logaritma
1.    konsep bilangan berpangkat, bentuk akar dan logaritma1.    konsep bilangan berpangkat, bentuk akar dan logaritma
1. konsep bilangan berpangkat, bentuk akar dan logaritma
 
Intalasi OJS 3.x Pada CPANEL (Fresh Install)
Intalasi OJS 3.x Pada CPANEL (Fresh Install)Intalasi OJS 3.x Pada CPANEL (Fresh Install)
Intalasi OJS 3.x Pada CPANEL (Fresh Install)
 
Handout kd 2.3 (tugas mid)
Handout kd 2.3 (tugas mid)Handout kd 2.3 (tugas mid)
Handout kd 2.3 (tugas mid)
 
Alat Peraga "BLAJAR" alias Blok Aljabar
Alat Peraga "BLAJAR" alias Blok AljabarAlat Peraga "BLAJAR" alias Blok Aljabar
Alat Peraga "BLAJAR" alias Blok Aljabar
 
ALUR TUJUAN PEMBELAJARAN MATEMATIKA KELAS VII
ALUR TUJUAN PEMBELAJARAN MATEMATIKA KELAS VIIALUR TUJUAN PEMBELAJARAN MATEMATIKA KELAS VII
ALUR TUJUAN PEMBELAJARAN MATEMATIKA KELAS VII
 
UMLtoNoSQL : From UML domain models to NoSQL Databases
UMLtoNoSQL : From UML domain models to NoSQL DatabasesUMLtoNoSQL : From UML domain models to NoSQL Databases
UMLtoNoSQL : From UML domain models to NoSQL Databases
 
24.algoritma knapsack
24.algoritma knapsack24.algoritma knapsack
24.algoritma knapsack
 
LIMIT FUNGSI (RPP & LKPD)
LIMIT FUNGSI (RPP & LKPD)LIMIT FUNGSI (RPP & LKPD)
LIMIT FUNGSI (RPP & LKPD)
 
Jaminan Kualitas Perangkat Lunak
Jaminan Kualitas Perangkat LunakJaminan Kualitas Perangkat Lunak
Jaminan Kualitas Perangkat Lunak
 
RPP Kelas X Materi Eksponen - Kurikulum 2013
RPP Kelas X Materi Eksponen - Kurikulum 2013RPP Kelas X Materi Eksponen - Kurikulum 2013
RPP Kelas X Materi Eksponen - Kurikulum 2013
 
DETERMINAN DAN INVERS MATRIKS 22.ppt
DETERMINAN DAN INVERS MATRIKS 22.pptDETERMINAN DAN INVERS MATRIKS 22.ppt
DETERMINAN DAN INVERS MATRIKS 22.ppt
 
Buku Siswa Barisan dan Deret
Buku Siswa Barisan dan DeretBuku Siswa Barisan dan Deret
Buku Siswa Barisan dan Deret
 
Modul Ajar Matematika Kelas 5 Fase C Kurikulum Merdeka [abdiera.com]
Modul Ajar Matematika Kelas 5 Fase C Kurikulum Merdeka [abdiera.com]Modul Ajar Matematika Kelas 5 Fase C Kurikulum Merdeka [abdiera.com]
Modul Ajar Matematika Kelas 5 Fase C Kurikulum Merdeka [abdiera.com]
 
RPP - Simpangan Kuartil
RPP - Simpangan KuartilRPP - Simpangan Kuartil
RPP - Simpangan Kuartil
 
Modul Ajar Persamaan Garis Lurus fix.pdf
Modul Ajar Persamaan Garis Lurus fix.pdfModul Ajar Persamaan Garis Lurus fix.pdf
Modul Ajar Persamaan Garis Lurus fix.pdf
 
Bab iii 5. memahami cara menyederhanakan bentuk aljabar
Bab iii   5. memahami cara menyederhanakan bentuk aljabarBab iii   5. memahami cara menyederhanakan bentuk aljabar
Bab iii 5. memahami cara menyederhanakan bentuk aljabar
 

Similar to Deep-dive into Reactive programming.pdf

Announcing: Native MQTT Integration with HiveMQ and InfluxDB Cloud
Announcing: Native MQTT Integration with HiveMQ and InfluxDB Cloud Announcing: Native MQTT Integration with HiveMQ and InfluxDB Cloud
Announcing: Native MQTT Integration with HiveMQ and InfluxDB Cloud
InfluxData
 
"Concurrent React 18. "I might do it later"", Mykola Yenin
"Concurrent React 18. "I might do it later"", Mykola Yenin "Concurrent React 18. "I might do it later"", Mykola Yenin
"Concurrent React 18. "I might do it later"", Mykola Yenin
Fwdays
 
CodiLime Tech Talk - Wojciech Urbański: Cloud Native
CodiLime Tech Talk - Wojciech Urbański: Cloud NativeCodiLime Tech Talk - Wojciech Urbański: Cloud Native
CodiLime Tech Talk - Wojciech Urbański: Cloud Native
CodiLime
 
CDK - The next big thing - Quang Phuong
CDK - The next big thing - Quang PhuongCDK - The next big thing - Quang Phuong
CDK - The next big thing - Quang Phuong
Vietnam Open Infrastructure User Group
 
RTP Bluemix Meetup April 20th 2016
RTP Bluemix Meetup April 20th 2016RTP Bluemix Meetup April 20th 2016
RTP Bluemix Meetup April 20th 2016
Tom Boucher
 
Master Real-Time Streams With Neo4j and Apache Kafka
Master Real-Time Streams With Neo4j and Apache KafkaMaster Real-Time Streams With Neo4j and Apache Kafka
Master Real-Time Streams With Neo4j and Apache Kafka
Neo4j
 
Infrastructure As Code
Infrastructure As CodeInfrastructure As Code
Infrastructure As Code
Yosef Tavin
 
Building Event-Driven Microservices using Kafka Streams (Stathis Souris, Thou...
Building Event-Driven Microservices using Kafka Streams (Stathis Souris, Thou...Building Event-Driven Microservices using Kafka Streams (Stathis Souris, Thou...
Building Event-Driven Microservices using Kafka Streams (Stathis Souris, Thou...
London Microservices
 
Second Presentation.pptx
Second Presentation.pptxSecond Presentation.pptx
Second Presentation.pptx
VikasMahor3
 
Dealing with large code bases. cd ams meetup
Dealing with large code bases. cd ams meetupDealing with large code bases. cd ams meetup
Dealing with large code bases. cd ams meetup
Viktor Sadovnikov
 
Kubernetes: Increasing velocity without sacrificing quality
Kubernetes: Increasing velocity without sacrificing qualityKubernetes: Increasing velocity without sacrificing quality
Kubernetes: Increasing velocity without sacrificing quality
Adam Schepis
 
Russ Savage [Ngrok] | InfluxDB QuickStart | InfluxDays NA 2021
Russ Savage [Ngrok] | InfluxDB QuickStart | InfluxDays NA 2021Russ Savage [Ngrok] | InfluxDB QuickStart | InfluxDays NA 2021
Russ Savage [Ngrok] | InfluxDB QuickStart | InfluxDays NA 2021
InfluxData
 
Enabling Devops using Jenkins
Enabling Devops using JenkinsEnabling Devops using Jenkins
Enabling Devops using Jenkins
Patrick Hynes
 
Building Event-Driven Workflows with Knative and Tekton
Building Event-Driven Workflows with Knative and TektonBuilding Event-Driven Workflows with Knative and Tekton
Building Event-Driven Workflows with Knative and Tekton
Leon Stigter
 
Web Performance & Latest in React
Web Performance & Latest in ReactWeb Performance & Latest in React
Web Performance & Latest in React
Talentica Software
 
Introduction to NodeJS
Introduction to NodeJSIntroduction to NodeJS
Introduction to NodeJS
Gobinda Karmakar ☁
 
Build Enterprise Level Solution using Logic Apps ,Functions and Graph API
Build Enterprise Level Solution using Logic Apps ,Functions and Graph API Build Enterprise Level Solution using Logic Apps ,Functions and Graph API
Build Enterprise Level Solution using Logic Apps ,Functions and Graph API
Abhishek Kumar
 
Background Tasks with Worker Service
Background Tasks with Worker ServiceBackground Tasks with Worker Service
Background Tasks with Worker Service
ssusere19c741
 
2020 03-26 - meet up - zparkio
2020 03-26 - meet up - zparkio2020 03-26 - meet up - zparkio
2020 03-26 - meet up - zparkio
Leo Benkel
 
Data Engineer's Lunch #86: Building Real-Time Applications at Scale: A Case S...
Data Engineer's Lunch #86: Building Real-Time Applications at Scale: A Case S...Data Engineer's Lunch #86: Building Real-Time Applications at Scale: A Case S...
Data Engineer's Lunch #86: Building Real-Time Applications at Scale: A Case S...
Anant Corporation
 

Similar to Deep-dive into Reactive programming.pdf (20)

Announcing: Native MQTT Integration with HiveMQ and InfluxDB Cloud
Announcing: Native MQTT Integration with HiveMQ and InfluxDB Cloud Announcing: Native MQTT Integration with HiveMQ and InfluxDB Cloud
Announcing: Native MQTT Integration with HiveMQ and InfluxDB Cloud
 
"Concurrent React 18. "I might do it later"", Mykola Yenin
"Concurrent React 18. "I might do it later"", Mykola Yenin "Concurrent React 18. "I might do it later"", Mykola Yenin
"Concurrent React 18. "I might do it later"", Mykola Yenin
 
CodiLime Tech Talk - Wojciech Urbański: Cloud Native
CodiLime Tech Talk - Wojciech Urbański: Cloud NativeCodiLime Tech Talk - Wojciech Urbański: Cloud Native
CodiLime Tech Talk - Wojciech Urbański: Cloud Native
 
CDK - The next big thing - Quang Phuong
CDK - The next big thing - Quang PhuongCDK - The next big thing - Quang Phuong
CDK - The next big thing - Quang Phuong
 
RTP Bluemix Meetup April 20th 2016
RTP Bluemix Meetup April 20th 2016RTP Bluemix Meetup April 20th 2016
RTP Bluemix Meetup April 20th 2016
 
Master Real-Time Streams With Neo4j and Apache Kafka
Master Real-Time Streams With Neo4j and Apache KafkaMaster Real-Time Streams With Neo4j and Apache Kafka
Master Real-Time Streams With Neo4j and Apache Kafka
 
Infrastructure As Code
Infrastructure As CodeInfrastructure As Code
Infrastructure As Code
 
Building Event-Driven Microservices using Kafka Streams (Stathis Souris, Thou...
Building Event-Driven Microservices using Kafka Streams (Stathis Souris, Thou...Building Event-Driven Microservices using Kafka Streams (Stathis Souris, Thou...
Building Event-Driven Microservices using Kafka Streams (Stathis Souris, Thou...
 
Second Presentation.pptx
Second Presentation.pptxSecond Presentation.pptx
Second Presentation.pptx
 
Dealing with large code bases. cd ams meetup
Dealing with large code bases. cd ams meetupDealing with large code bases. cd ams meetup
Dealing with large code bases. cd ams meetup
 
Kubernetes: Increasing velocity without sacrificing quality
Kubernetes: Increasing velocity without sacrificing qualityKubernetes: Increasing velocity without sacrificing quality
Kubernetes: Increasing velocity without sacrificing quality
 
Russ Savage [Ngrok] | InfluxDB QuickStart | InfluxDays NA 2021
Russ Savage [Ngrok] | InfluxDB QuickStart | InfluxDays NA 2021Russ Savage [Ngrok] | InfluxDB QuickStart | InfluxDays NA 2021
Russ Savage [Ngrok] | InfluxDB QuickStart | InfluxDays NA 2021
 
Enabling Devops using Jenkins
Enabling Devops using JenkinsEnabling Devops using Jenkins
Enabling Devops using Jenkins
 
Building Event-Driven Workflows with Knative and Tekton
Building Event-Driven Workflows with Knative and TektonBuilding Event-Driven Workflows with Knative and Tekton
Building Event-Driven Workflows with Knative and Tekton
 
Web Performance & Latest in React
Web Performance & Latest in ReactWeb Performance & Latest in React
Web Performance & Latest in React
 
Introduction to NodeJS
Introduction to NodeJSIntroduction to NodeJS
Introduction to NodeJS
 
Build Enterprise Level Solution using Logic Apps ,Functions and Graph API
Build Enterprise Level Solution using Logic Apps ,Functions and Graph API Build Enterprise Level Solution using Logic Apps ,Functions and Graph API
Build Enterprise Level Solution using Logic Apps ,Functions and Graph API
 
Background Tasks with Worker Service
Background Tasks with Worker ServiceBackground Tasks with Worker Service
Background Tasks with Worker Service
 
2020 03-26 - meet up - zparkio
2020 03-26 - meet up - zparkio2020 03-26 - meet up - zparkio
2020 03-26 - meet up - zparkio
 
Data Engineer's Lunch #86: Building Real-Time Applications at Scale: A Case S...
Data Engineer's Lunch #86: Building Real-Time Applications at Scale: A Case S...Data Engineer's Lunch #86: Building Real-Time Applications at Scale: A Case S...
Data Engineer's Lunch #86: Building Real-Time Applications at Scale: A Case S...
 

Recently uploaded

LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
Anant Corporation
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
Rahul
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
sachin chaurasia
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
IJECEIAES
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
co23btech11018
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
MDSABBIROJJAMANPAYEL
 
john krisinger-the science and history of the alcoholic beverage.pptx
john krisinger-the science and history of the alcoholic beverage.pptxjohn krisinger-the science and history of the alcoholic beverage.pptx
john krisinger-the science and history of the alcoholic beverage.pptx
Madan Karki
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
NazakatAliKhoso2
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
Dr Ramhari Poudyal
 
UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...
UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...
UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...
amsjournal
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
kandramariana6
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
shadow0702a
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
IJECEIAES
 
Certificates - Mahmoud Mohamed Moursi Ahmed
Certificates - Mahmoud Mohamed Moursi AhmedCertificates - Mahmoud Mohamed Moursi Ahmed
Certificates - Mahmoud Mohamed Moursi Ahmed
Mahmoud Morsy
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
bijceesjournal
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
Madan Karki
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
RamonNovais6
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
SUTEJAS
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Christina Lin
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
jpsjournal1
 

Recently uploaded (20)

LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by AnantLLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
LLM Fine Tuning with QLoRA Cassandra Lunch 4, presented by Anant
 
ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024ACEP Magazine edition 4th launched on 05.06.2024
ACEP Magazine edition 4th launched on 05.06.2024
 
The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.The Python for beginners. This is an advance computer language.
The Python for beginners. This is an advance computer language.
 
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
Redefining brain tumor segmentation: a cutting-edge convolutional neural netw...
 
Computational Engineering IITH Presentation
Computational Engineering IITH PresentationComputational Engineering IITH Presentation
Computational Engineering IITH Presentation
 
Properties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptxProperties Railway Sleepers and Test.pptx
Properties Railway Sleepers and Test.pptx
 
john krisinger-the science and history of the alcoholic beverage.pptx
john krisinger-the science and history of the alcoholic beverage.pptxjohn krisinger-the science and history of the alcoholic beverage.pptx
john krisinger-the science and history of the alcoholic beverage.pptx
 
Textile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdfTextile Chemical Processing and Dyeing.pdf
Textile Chemical Processing and Dyeing.pdf
 
Literature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptxLiterature Review Basics and Understanding Reference Management.pptx
Literature Review Basics and Understanding Reference Management.pptx
 
UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...
UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...
UNLOCKING HEALTHCARE 4.0: NAVIGATING CRITICAL SUCCESS FACTORS FOR EFFECTIVE I...
 
132/33KV substation case study Presentation
132/33KV substation case study Presentation132/33KV substation case study Presentation
132/33KV substation case study Presentation
 
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
Use PyCharm for remote debugging of WSL on a Windo cf5c162d672e4e58b4dde5d797...
 
Embedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoringEmbedded machine learning-based road conditions and driving behavior monitoring
Embedded machine learning-based road conditions and driving behavior monitoring
 
Certificates - Mahmoud Mohamed Moursi Ahmed
Certificates - Mahmoud Mohamed Moursi AhmedCertificates - Mahmoud Mohamed Moursi Ahmed
Certificates - Mahmoud Mohamed Moursi Ahmed
 
Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...Comparative analysis between traditional aquaponics and reconstructed aquapon...
Comparative analysis between traditional aquaponics and reconstructed aquapon...
 
Manufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptxManufacturing Process of molasses based distillery ppt.pptx
Manufacturing Process of molasses based distillery ppt.pptx
 
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURSCompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
CompEx~Manual~1210 (2).pdf COMPEX GAS AND VAPOURS
 
Understanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine LearningUnderstanding Inductive Bias in Machine Learning
Understanding Inductive Bias in Machine Learning
 
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming PipelinesHarnessing WebAssembly for Real-time Stateless Streaming Pipelines
Harnessing WebAssembly for Real-time Stateless Streaming Pipelines
 
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECTCHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
CHINA’S GEO-ECONOMIC OUTREACH IN CENTRAL ASIAN COUNTRIES AND FUTURE PROSPECT
 

Deep-dive into Reactive programming.pdf

  • 1. © 2022 Thoughtworks | Confidential Reactive Programming Mritunjay Dubey & Kumar Sankara Iyer
  • 2. © 2022 Thoughtworks | Confidential Table of contents Setup 03 Threading models and Demo 04 Reactive programming concepts and Spring Webflux 05 Reactive Data types & Operators and hands-on 06 Corner cases, Error handling and hands-on 07 Reactor context demo 10 Demo of end-to-end streams 13 Miscellaneous topics 17 2
  • 3. © 2022 Thoughtworks | Confidential Setup 3
  • 4. © 2022 Thoughtworks | Confidential Prerequisites for hands-on 1. Install Java 17 (preferred) 2. Use an IDE like Intellij 3. Install Git (good to have) 4. Install Postman (good to have) 5. Clone the code from https://github.com/reactive-workshop/reactive-building-blocks 6. Run ./gradlew bootRun 7. Import Reactive-Workshop.postman_collectioninto Postman and run the first API “Get User By User Id” 4
  • 5. © 2022 Thoughtworks | Confidential Threading models 5
  • 6. © 2022 Thoughtworks | Confidential Thread-per-request model 6
  • 7. © 2022 Thoughtworks | Confidential Drawbacks of the thread-per-request model The thread-per-request model is neither performant not scalable Context switching is expensive Threads are blocked while I/O is in progress 7 A thread takes a minimum of 1 MB of stack size Threads increase as the number of requests
  • 8. © 2022 Thoughtworks | Confidential Event-loop model 8
  • 9. © 2022 Thoughtworks | Confidential Netty 9 A framework to create asynchronous, event-driven applications
  • 10. © 2022 Thoughtworks | Confidential Demo on threading models 10
  • 11. © 2022 Thoughtworks | Confidential Reactive programming concepts and Spring Webflux 11
  • 12. © 2022 Thoughtworks | Confidential 12 Asynchronous 1. Reactive streams There are several implementations of the Reactive streams specification - RxJava, Reactor, Akka streams, RxJavaScript and so on A standard for asynchronous stream processing Non-blocking 2. Backpressure 3. 12 © 2022 Thoughtworks
  • 13. © 2022 Thoughtworks | Confidential Reactive streams - some keywords 13
  • 14. © 2022 Thoughtworks | Confidential Spring Webflux 14 A fully Reactive framework that embraces Functional Reactive Programming
  • 15. © 2022 Thoughtworks | Confidential Reactive Data types & Operators 15
  • 16. © 2022 Thoughtworks | Confidential Mono Mono is a Reactive Streams Publisher that emits at most one item and then terminates 16 16 For eg;
  • 17. © 2022 Thoughtworks | Confidential Flux Flux is a Reactive Streams Publisher that emits 0 to N elements and then completes 17 17 For eg;
  • 18. © 2022 Thoughtworks | Confidential map 18 18 © 2022 Thoughtworks Transforms a Flux to another Flux by applying a synchronous function to each item
  • 19. © 2022 Thoughtworks | Confidential flatMap 19 19 © 2022 Thoughtworks Flatten the inner publishers into a single Flux through merging, allowing them to interleave
  • 20. © 2022 Thoughtworks | Confidential filter 20 20 © 2022 Thoughtworks Evaluate each source value against the given predicate
  • 21. © 2022 Thoughtworks | Confidential zip 21 21 © 2022 Thoughtworks Wait for all sources to emit one element, then combine these elements. Continue till any of the sources complete
  • 22. © 2022 Thoughtworks | Confidential Hands-on with Reactor operators 22
  • 23. © 2022 Thoughtworks | Confidential Corner cases and Error handling 23
  • 24. © 2022 Thoughtworks | Confidential switchIfEmpty 24 24 © 2022 Thoughtworks Switch to an alternative publisher if this publisher is empty
  • 25. © 2022 Thoughtworks | Confidential onErrorMap 25 25 © 2022 Thoughtworks Transform a source error to another error
  • 26. © 2022 Thoughtworks | Confidential onErrorResume 26 26 © 2022 Thoughtworks Subscribe to a fallback publisher if any error happens in source
  • 27. © 2022 Thoughtworks | Confidential Hands-on with error handling 27
  • 28. © 2022 Thoughtworks | Confidential Reactor context - a demo 28
  • 29. © 2022 Thoughtworks | Confidential End-to-end streams - a demo 29
  • 30. © 2022 Thoughtworks | Confidential Miscellaneous 30
  • 31. © 2022 Thoughtworks | Confidential Reactive programming is fun! Building and running on reactive applications on production requires Further reading Learning curve 31 Blocking calls A word on Testing
  • 32. © 2022 Thoughtworks | Confidential Discussion 32
  • 33. © 2022 Thoughtworks | Confidential Thankyou 33