SlideShare a Scribd company logo
1 of 45
Reactive programming
with Spring Reactor
The new normal that is not new
Reactive
programming
A paradigm to compose asynchronous and event-
based sequences, using non-blocking operators.
Reactive
programming
A paradigm to compose asynchronous and event-
based sequences, using non-blocking operators.
To block or not
to block? To
sync or not
sync?
• Async/Non-
Blocking• Sync/Non-blocking
• Async/Blocking• Sync/Blocking
Synchronous & blocking
Resume
Synchronous & non-blocking
Resume
Asynchronous & blocking
Resume
Asynchronous & non-blocking
Resume
So… async & non
blocking uh!?
How about
change
propagation?
Reactive
programming
A paradigm to compose asynchronous and event-
based sequences, using non-blocking operators.
Alice finishes work
Order pizza
Pick up Bob
Makes it home
Synchronous
Alice phone to orders
pizza
Invite Bob to come
Heads home
Has pizza delivered
Starts without waiting
for Bob
Asynchronous
Alice phone to orders
pizza
Invite Bob to come
Heads home
Has pizza delivered
Wait for Bob and turns
the movie on
Reactive
Reactive
approach to
change
propagation
Wait until all asynchronous actions are complete
and then proceed with further actions.
Interesting… how
to achieve that in
Java without
losing my skull
mind?
Spring Reactor
CAUTION
BUZZ WORDS
AHEAD
• A specification for building modern, cloud-scale architectures
• which are responsive, resilient, elastic and message driven.
Reactive manifesto
• A system that fulfill the reactive manifesto.
Reactive system
• A specification much like JPA or JDBC, product of a collaboration
• between engineers from Netflix, Pivotal, Red Hat, Twitter,
• Typesafe, and many others.
Reactive Streams
• A specification for denotative continuous-time programming.
• Most libraries claiming to support functional reactive
• programming are almost exclusively talking about reactive
• programming.
Functional reactive programming
• An asynchronous programming paradigm concerned with data
• streams and the propagation of change.
Reactive programming
Thinking in Reactive
The hardest part of this journey
is thinking in Reactive.
It's a lot about letting go of old
imperative and stateful habits of
typical programming and forcing
your brain to work in a different
paradigm.
Do I have to make
it all reactive?
Only consider reactive programming when dealing
with huge volumes of data or multi-userness.
Imperative Reactive
Hello Reactive
Push event
Publisher Subscriber
Backpressure
Hybrid push-pull
..
Flux
I wish I
had more
celeries
How
many?
Mono
..
Defining a Publisher
Defining a Subscriber
Mmm… we could
have returned a
List<Greeting>
couldn’t we?
Server-Sent
Events
An HTTP standard that allows a web application
to handle a unidirectional event stream and
receive updates whenever server emits data.
Is it not like a
WebSocket?
Show me the
code!
A simple reactive server
Why does
it take so long?
RestTemplate uses the Java Servlet API, which is based
on the thread-per-request model [sync/blocking].
WebClient uses an asynchronous, non-blocking solution
provided by the Spring Reactive framework.
WebClient
rocks!
No subscription – No data
Introduction to Spring Reactor

More Related Content

What's hot

Challenges of moving a java team to scala
Challenges of moving a java team to scalaChallenges of moving a java team to scala
Challenges of moving a java team to scalaJoão Cavalheiro
 
CoffeeScript the Awesome
CoffeeScript the AwesomeCoffeeScript the Awesome
CoffeeScript the AwesomeJames Hughes
 
A Whirlwind Tour of Etsy's Monitoring Stack
A Whirlwind Tour of Etsy's Monitoring StackA Whirlwind Tour of Etsy's Monitoring Stack
A Whirlwind Tour of Etsy's Monitoring StackDaniel Schauenberg
 
Seven deadly wastes
Seven deadly wastesSeven deadly wastes
Seven deadly wastesJez Halford
 
Is Serverless The New Swiss Cheese?
Is Serverless The New Swiss Cheese?Is Serverless The New Swiss Cheese?
Is Serverless The New Swiss Cheese?Chase Douglas
 
Ruby Testing: Cucumber and RSpec
Ruby Testing: Cucumber and RSpecRuby Testing: Cucumber and RSpec
Ruby Testing: Cucumber and RSpecJames Thompson
 
Going faster with kanban
Going faster with kanbanGoing faster with kanban
Going faster with kanbanJez Halford
 
Coolblue Behind the Scenes | Jeffrey Simons - The UX nerd and you.
Coolblue Behind the Scenes | Jeffrey Simons - The UX nerd and you.Coolblue Behind the Scenes | Jeffrey Simons - The UX nerd and you.
Coolblue Behind the Scenes | Jeffrey Simons - The UX nerd and you.Coolblue
 
8 Simple Rules for Consuming APIs
8 Simple Rules for Consuming APIs8 Simple Rules for Consuming APIs
8 Simple Rules for Consuming APIsSteven Wade
 
Learn Kanban - Agile Software Development Methodology
Learn Kanban - Agile Software Development MethodologyLearn Kanban - Agile Software Development Methodology
Learn Kanban - Agile Software Development MethodologyAltaf Najvani
 
Playing nice with the MEAN stack
Playing nice with the MEAN stackPlaying nice with the MEAN stack
Playing nice with the MEAN stackAspenware
 
Reactive Streams and the Wide World of Groovy
Reactive Streams and the Wide World of GroovyReactive Streams and the Wide World of Groovy
Reactive Streams and the Wide World of GroovySteve Pember
 
Baptism By Fire - Why production issues make you a better developer
Baptism By Fire - Why production issues make you a better developerBaptism By Fire - Why production issues make you a better developer
Baptism By Fire - Why production issues make you a better developerAdi Belan
 
Episode 19 - Asynchronous Apex - Batch apex & schedulers
Episode 19 - Asynchronous Apex - Batch apex & schedulersEpisode 19 - Asynchronous Apex - Batch apex & schedulers
Episode 19 - Asynchronous Apex - Batch apex & schedulersJitendra Zaa
 
Benchmarking: You're Doing It Wrong (StrangeLoop 2014)
Benchmarking: You're Doing It Wrong (StrangeLoop 2014)Benchmarking: You're Doing It Wrong (StrangeLoop 2014)
Benchmarking: You're Doing It Wrong (StrangeLoop 2014)Aysylu Greenberg
 
Intro to Agile Processes for Developers
Intro to Agile Processes for DevelopersIntro to Agile Processes for Developers
Intro to Agile Processes for DevelopersWade Armstrong
 
Lets go to the background
Lets go to the backgroundLets go to the background
Lets go to the backgroundRan Wahle
 

What's hot (20)

Challenges of moving a java team to scala
Challenges of moving a java team to scalaChallenges of moving a java team to scala
Challenges of moving a java team to scala
 
CoffeeScript the Awesome
CoffeeScript the AwesomeCoffeeScript the Awesome
CoffeeScript the Awesome
 
A Whirlwind Tour of Etsy's Monitoring Stack
A Whirlwind Tour of Etsy's Monitoring StackA Whirlwind Tour of Etsy's Monitoring Stack
A Whirlwind Tour of Etsy's Monitoring Stack
 
Data Driven Monitoring
Data Driven MonitoringData Driven Monitoring
Data Driven Monitoring
 
Seven deadly wastes
Seven deadly wastesSeven deadly wastes
Seven deadly wastes
 
Is Serverless The New Swiss Cheese?
Is Serverless The New Swiss Cheese?Is Serverless The New Swiss Cheese?
Is Serverless The New Swiss Cheese?
 
Ruby Testing: Cucumber and RSpec
Ruby Testing: Cucumber and RSpecRuby Testing: Cucumber and RSpec
Ruby Testing: Cucumber and RSpec
 
Going faster with kanban
Going faster with kanbanGoing faster with kanban
Going faster with kanban
 
Coolblue Behind the Scenes | Jeffrey Simons - The UX nerd and you.
Coolblue Behind the Scenes | Jeffrey Simons - The UX nerd and you.Coolblue Behind the Scenes | Jeffrey Simons - The UX nerd and you.
Coolblue Behind the Scenes | Jeffrey Simons - The UX nerd and you.
 
Rally - How to use it
Rally - How to use itRally - How to use it
Rally - How to use it
 
8 Simple Rules for Consuming APIs
8 Simple Rules for Consuming APIs8 Simple Rules for Consuming APIs
8 Simple Rules for Consuming APIs
 
Learn Kanban - Agile Software Development Methodology
Learn Kanban - Agile Software Development MethodologyLearn Kanban - Agile Software Development Methodology
Learn Kanban - Agile Software Development Methodology
 
Playing nice with the MEAN stack
Playing nice with the MEAN stackPlaying nice with the MEAN stack
Playing nice with the MEAN stack
 
Capistrano @ VilniusPHP
Capistrano @ VilniusPHPCapistrano @ VilniusPHP
Capistrano @ VilniusPHP
 
Reactive Streams and the Wide World of Groovy
Reactive Streams and the Wide World of GroovyReactive Streams and the Wide World of Groovy
Reactive Streams and the Wide World of Groovy
 
Baptism By Fire - Why production issues make you a better developer
Baptism By Fire - Why production issues make you a better developerBaptism By Fire - Why production issues make you a better developer
Baptism By Fire - Why production issues make you a better developer
 
Episode 19 - Asynchronous Apex - Batch apex & schedulers
Episode 19 - Asynchronous Apex - Batch apex & schedulersEpisode 19 - Asynchronous Apex - Batch apex & schedulers
Episode 19 - Asynchronous Apex - Batch apex & schedulers
 
Benchmarking: You're Doing It Wrong (StrangeLoop 2014)
Benchmarking: You're Doing It Wrong (StrangeLoop 2014)Benchmarking: You're Doing It Wrong (StrangeLoop 2014)
Benchmarking: You're Doing It Wrong (StrangeLoop 2014)
 
Intro to Agile Processes for Developers
Intro to Agile Processes for DevelopersIntro to Agile Processes for Developers
Intro to Agile Processes for Developers
 
Lets go to the background
Lets go to the backgroundLets go to the background
Lets go to the background
 

Similar to Introduction to Spring Reactor

Reactive All the Way Down the Stack
Reactive All the Way Down the StackReactive All the Way Down the Stack
Reactive All the Way Down the StackSteve Pember
 
Chris Mathias Presents Advanced API Design Considerations at LA CTO Forum
Chris Mathias Presents Advanced API Design Considerations at LA CTO ForumChris Mathias Presents Advanced API Design Considerations at LA CTO Forum
Chris Mathias Presents Advanced API Design Considerations at LA CTO ForumChris Mathias
 
reactive_programming_for_java_developers.pdf
reactive_programming_for_java_developers.pdfreactive_programming_for_java_developers.pdf
reactive_programming_for_java_developers.pdfAkshitkumar437417
 
An introduction to Reactive applications, Reactive Streams, and options for t...
An introduction to Reactive applications, Reactive Streams, and options for t...An introduction to Reactive applications, Reactive Streams, and options for t...
An introduction to Reactive applications, Reactive Streams, and options for t...Steve Pember
 
Highly concurrent yet natural programming
Highly concurrent yet natural programmingHighly concurrent yet natural programming
Highly concurrent yet natural programmingInfinit
 
[DevDay 2017] ReactJS Hands on - Speaker: Binh Phan - Developer at mgm techno...
[DevDay 2017] ReactJS Hands on - Speaker: Binh Phan - Developer at mgm techno...[DevDay 2017] ReactJS Hands on - Speaker: Binh Phan - Developer at mgm techno...
[DevDay 2017] ReactJS Hands on - Speaker: Binh Phan - Developer at mgm techno...DevDay.org
 
A Tale of Two Workflows - ChefConf 2014
A Tale of Two Workflows - ChefConf 2014A Tale of Two Workflows - ChefConf 2014
A Tale of Two Workflows - ChefConf 2014Pete Cheslock
 
Reactive Programming or Reactive Systems? (spoiler: both)
Reactive Programming or Reactive Systems? (spoiler: both)Reactive Programming or Reactive Systems? (spoiler: both)
Reactive Programming or Reactive Systems? (spoiler: both)Fabio Tiriticco
 
Increasing velocity via serless semantics
Increasing velocity via serless semanticsIncreasing velocity via serless semantics
Increasing velocity via serless semanticsKfir Bloch
 
Synchronous Reads Asynchronous Writes RubyConf 2009
Synchronous Reads Asynchronous Writes RubyConf 2009Synchronous Reads Asynchronous Writes RubyConf 2009
Synchronous Reads Asynchronous Writes RubyConf 2009pauldix
 
A first look into the Project Loom in Java
A first look into the Project Loom in JavaA first look into the Project Loom in Java
A first look into the Project Loom in JavaLukas Steinbrecher
 
Responsive, adaptive and responsible - keynote at NebraskaJS
Responsive, adaptive and responsible - keynote at NebraskaJSResponsive, adaptive and responsible - keynote at NebraskaJS
Responsive, adaptive and responsible - keynote at NebraskaJSChristian Heilmann
 
A Call for Sanity in NoSQL
A Call for Sanity in NoSQLA Call for Sanity in NoSQL
A Call for Sanity in NoSQLC4Media
 
Hacking Real time Messaging with Firebase
Hacking Real time Messaging with FirebaseHacking Real time Messaging with Firebase
Hacking Real time Messaging with FirebaseArtur Daschevici
 
High Availability SOA APP with GlusterFS
High Availability SOA APP with GlusterFSHigh Availability SOA APP with GlusterFS
High Availability SOA APP with GlusterFSzeridon
 
Reactive solutions using java 9 and spring reactor
Reactive solutions using java 9 and spring reactorReactive solutions using java 9 and spring reactor
Reactive solutions using java 9 and spring reactorOrenEzer1
 
An Introduction to Reactive Application, Reactive Streams, and options for JVM
An Introduction to Reactive Application, Reactive Streams, and options for JVMAn Introduction to Reactive Application, Reactive Streams, and options for JVM
An Introduction to Reactive Application, Reactive Streams, and options for JVMSteve Pember
 
Background processes and tasks in an async world
Background processes and tasks in an async worldBackground processes and tasks in an async world
Background processes and tasks in an async worldparticlebanana
 

Similar to Introduction to Spring Reactor (20)

Reactive All the Way Down the Stack
Reactive All the Way Down the StackReactive All the Way Down the Stack
Reactive All the Way Down the Stack
 
Chris Mathias Presents Advanced API Design Considerations at LA CTO Forum
Chris Mathias Presents Advanced API Design Considerations at LA CTO ForumChris Mathias Presents Advanced API Design Considerations at LA CTO Forum
Chris Mathias Presents Advanced API Design Considerations at LA CTO Forum
 
reactive_programming_for_java_developers.pdf
reactive_programming_for_java_developers.pdfreactive_programming_for_java_developers.pdf
reactive_programming_for_java_developers.pdf
 
An introduction to Reactive applications, Reactive Streams, and options for t...
An introduction to Reactive applications, Reactive Streams, and options for t...An introduction to Reactive applications, Reactive Streams, and options for t...
An introduction to Reactive applications, Reactive Streams, and options for t...
 
Highly concurrent yet natural programming
Highly concurrent yet natural programmingHighly concurrent yet natural programming
Highly concurrent yet natural programming
 
[DevDay 2017] ReactJS Hands on - Speaker: Binh Phan - Developer at mgm techno...
[DevDay 2017] ReactJS Hands on - Speaker: Binh Phan - Developer at mgm techno...[DevDay 2017] ReactJS Hands on - Speaker: Binh Phan - Developer at mgm techno...
[DevDay 2017] ReactJS Hands on - Speaker: Binh Phan - Developer at mgm techno...
 
A Tale of Two Workflows - ChefConf 2014
A Tale of Two Workflows - ChefConf 2014A Tale of Two Workflows - ChefConf 2014
A Tale of Two Workflows - ChefConf 2014
 
Reactive Programming or Reactive Systems? (spoiler: both)
Reactive Programming or Reactive Systems? (spoiler: both)Reactive Programming or Reactive Systems? (spoiler: both)
Reactive Programming or Reactive Systems? (spoiler: both)
 
Increasing velocity via serless semantics
Increasing velocity via serless semanticsIncreasing velocity via serless semantics
Increasing velocity via serless semantics
 
Dev Ops without the Ops
Dev Ops without the OpsDev Ops without the Ops
Dev Ops without the Ops
 
Synchronous Reads Asynchronous Writes RubyConf 2009
Synchronous Reads Asynchronous Writes RubyConf 2009Synchronous Reads Asynchronous Writes RubyConf 2009
Synchronous Reads Asynchronous Writes RubyConf 2009
 
A first look into the Project Loom in Java
A first look into the Project Loom in JavaA first look into the Project Loom in Java
A first look into the Project Loom in Java
 
Responsive, adaptive and responsible - keynote at NebraskaJS
Responsive, adaptive and responsible - keynote at NebraskaJSResponsive, adaptive and responsible - keynote at NebraskaJS
Responsive, adaptive and responsible - keynote at NebraskaJS
 
A Call for Sanity in NoSQL
A Call for Sanity in NoSQLA Call for Sanity in NoSQL
A Call for Sanity in NoSQL
 
Hacking Real time Messaging with Firebase
Hacking Real time Messaging with FirebaseHacking Real time Messaging with Firebase
Hacking Real time Messaging with Firebase
 
High Availability SOA APP with GlusterFS
High Availability SOA APP with GlusterFSHigh Availability SOA APP with GlusterFS
High Availability SOA APP with GlusterFS
 
Reactive solutions using java 9 and spring reactor
Reactive solutions using java 9 and spring reactorReactive solutions using java 9 and spring reactor
Reactive solutions using java 9 and spring reactor
 
An Introduction to Reactive Application, Reactive Streams, and options for JVM
An Introduction to Reactive Application, Reactive Streams, and options for JVMAn Introduction to Reactive Application, Reactive Streams, and options for JVM
An Introduction to Reactive Application, Reactive Streams, and options for JVM
 
Performance Tuning with XHProf
Performance Tuning with XHProfPerformance Tuning with XHProf
Performance Tuning with XHProf
 
Background processes and tasks in an async world
Background processes and tasks in an async worldBackground processes and tasks in an async world
Background processes and tasks in an async world
 

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
 
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
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...software pro Development
 
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
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
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
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsAndolasoft Inc
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerThousandEyes
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfryanfarris8
 
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
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
+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
 
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
 
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
 

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
 
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
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...How to Choose the Right Laravel Development Partner in New York City_compress...
How to Choose the Right Laravel Development Partner in New York City_compress...
 
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 ...
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
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
 
How To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.jsHow To Use Server-Side Rendering with Nuxt.js
How To Use Server-Side Rendering with Nuxt.js
 
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected WorkerHow To Troubleshoot Collaboration Apps for the Modern Connected Worker
How To Troubleshoot Collaboration Apps for the Modern Connected Worker
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdfAzure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
Azure_Native_Qumulo_High_Performance_Compute_Benchmarks.pdf
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
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 ...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
+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
 
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 🔝✔️✔️
 
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 Spring Reactor

Editor's Notes

  1. Let’s focus on two keywords here.
  2. From the application's perspective, the read call spans a long duration. But, in fact, the application is actually blocked while the read is multiplexed with other work in the kernel.
  3. The implication of non-blocking is that an I/O command may not be satisfied immediately, requiring that the application make numerous calls to await completion. This can be extremely inefficient because in many cases the application must busy-wait until the data is available or attempt to do other work while the command is performed in the kernel. As also shown in Figure, this method can introduce latency in the I/O because any gap between the data becoming available in the kernel and the user calling read to return it can reduce the overall data throughput.
  4. In this model, non-blocking I/O is configured, and then the blocking select system call is used to determine when there's any activity for an I/O descriptor. The primary issue with the select call is that it's not very efficient. While it's a convenient model for asynchronous notification, its use for high-performance I/O is not advised.
  5. The read request returns immediately, indicating that the read was successfully initiated. The application can then perform other processing while the background read operation completes. When the read response arrives, a signal or a thread-based callback can be generated to complete the I/O transaction. The ability to overlap computation and I/O processing in a single process for potentially multiple I/O requests exploits the gap between processing speed and I/O speed. While one or more slow I/O requests are pending, the CPU can perform other tasks or, more commonly, operate on already completed I/Os while other I/Os are initiated.
  6. Let’s focus on two keywords here.
  7. Here’s a real-life example. Say, it’s Friday and Alice wants to spend this evening with his friend Bob, scarfing pizza and watching one of the Star Wars episodes. Let’s outline the options she has. Alice finishes her work. Then goes and orders the pizza, waits till it’s done. Then picks up her friend. And finally (with Bob and pizza) makes it home and gets down to the movie. It will be the sync approach and it will be way too long, so that probably Alice will have wanted to call the thing off by that time.
  8. Alice orders his pizza online, phones Bob, invites him to come. She heads home, has her pizza delivered and starts watching the movie (and eating the pizza) without waiting for Bob to show up. That is what can happen with the async approach. 
  9. Alice orders pizza, phones Bob, invites him to come, heads home, and gets his pizza delivered. But this time, he waits until Bob comes and only after that he turns the movie on. This is what the reactive approach is about. You wait till all async actions (changes) are completed and then proceed with further actions.  
  10. Here’s a real-life example. Say, it’s Friday and John wants to spend this evening with his friend Bob, scarfing pizza and watching one of the Star Wars episodes. Let’s outline the options he has.
  11. Reactive is a set of design principles a way of thinking about systems architecture and design in a distributed environment where implementation techniques, tooling, and design patterns are components of a larger whole—a system. It’s possible to write a single application in a reactive style (i.e. using reactive programming); however, that’s merely one piece of the puzzle. Though each of the above aspects may seem to qualify as “reactive,” in and of themselves they do not make a system reactive.
  12. At the beginning always sits a data producer, the keyboard in that case. At the end of the data flow, represented by the tubes above, there is a subscriber/listener. The subscriber/listener wants to act on the result, for example, to update the UI of your software. In between, you have connectors, also called Operators: Here we have a filter connector and a map connector that manipulate data when it flows through the tube. That’s how you model all of your data flows if you use libraries like RxJava.
  13. Publisher - A Publisher is a provider of a potentially unbounded number of elements. Subscriber - A Subscriber listens to that Publisher, asking for new data. Sometimes, it's also referred to as a Consumer. Backpressure - The ability of the Subscriber to let the Publisher how many requests can it handle at the time. So it's the Subscriber that is responsible for the flow of the data, not the Publisher as it just provides the data. Flux - is a publisher that produces 0 to N values. It could be unbounded. Operations that return multiple elements use this type. Mono - is a publisher that produces 0 to 1 value. Operations that return a single element use this type.
  14. Code @ https://gitlab.nonprod.dwpcloud.uk/simone.di-cola/spring-reactive
  15. Click on the screenshot
  16. Click on the screenshot
  17. Suppose we had a publisher that returned more than a thousand records, or even more. Think of what the framework has to do. It's given an object of type Greeting, which it has to convert to JSON for the end user. Had we used the traditional approach with Spring MVC, these objects would keep on accumulating in your RAM and once it collects everything it would return it to the client. This might exceed our RAM capacity and also blocks any other operation from getting processed in the meantime. When we use Spring Webflux, the whole internal dynamics get changed. The framework starts subscribing to these records from the publisher and it serializes each item and sends it back to the client in chunks. We do things asynchronously without creating too many threads and reusing the threads that are waiting for something. The best part it is that you don't have to do anything extra for this. In traditional Spring MVC, we could achieve the same by returning AsyncResult, DefferedResult, etc. to get some asynchronicity, but internally Spring MVC had to create a new Thread, which gets blocked since it has to wait.
  18. These events allow a web page to get updates from a server in real-time.
  19. It's advised to use Flux and Mono over Publisher. Both of these classes are implementations of the Publisher interface originating from Reactive Streams. While you can use them interchangeably, it's more expressive and descriptive to use the implementations. .delayElements()- This method delays each element of the Flux by the given duration .zip() - We're defining a Flux to generate events, and a Flux to generate values each second. By zipping them together, we get a Flux generating events each second.
  20. We initialized a list of type Person and based on the id passed to our mapping, we filter that person out using a stream. You might be alarmed by the usage of Thread.sleep() here, though it's just used to simulate network lag of 2 seconds.
  21. As expected it took a little over 10 secs and this is how Spring MVC works by default. At this day and age, waiting for a little over 10 seconds for a result on a page is unacceptable. This is the difference between keeping a customer/client and losing it due to waiting for too long. Spring Reactor introduced a new web client to make web requests called WebClient. Compared to RestTemplate, this client has a more functional feel and is fully reactive. It's included in the spring-boot-starter-weblux dependency and it's build to replace RestTemplate in a non-blocking way. Let's rewrite the same controller, this time, using WebClient:
  22. This means that the thread will block until the web client receives the response. The problem with the blocking code is due to each thread consuming some amount of memory and CPU cycles. Let's consider having a lot of incoming requests, which are waiting for some slow service needed to produce the result. Sooner or later, the requests waiting for the results will pile up. Consequently, the application will create many threads, which will exhaust the thread pool or occupy all the available memory. We can also experience performance degradation because of the frequent CPU context (thread) switching.
  23. Here, we created a WebClient by passing the baseUrl. Then in the main method, we simply call the endpoint. get() indicates that we are making a GET request. We know that the response will be a single object, so we're using a Mono as explained before. Ultimately, we asked Spring to map the response to a Person class: And nothing happened, as expected.
  24. If you look closely at the threads, Reactor is reusing them rather than creating new ones. This is really important if your application handles many requests in a short span of time.