SlideShare a Scribd company logo
1 of 19
Reactive Spring 5
(AKA Functional Reactive Programming with Spring)
Why I chose this talk?
A definition
Reactive Programming is all about non-blocking applications
that are asynchronous and event-driven and require a small
number of threads to scale
-Spring.io
What is Reactive Programming?
• Observer
• Interface to notify an object that the
next item in a sequence it is watching
it is available
• Streams
• Controlled exchange of stream data
across Applications
• Back-pressure
• control the flow of a Stream between
producer and consumer
What is Functional Reactive Programming?
Conal Elliot defined FRP back in 1998, in his paper "Functional
Reactive Animation”:
• “FRP expressions describe entire evolutions of values over
time, representing these evolutions directly as first-class
values
What is Functional reactive programming?
• Compositionality
• Being able to compose functions
• Immutability
• Guarantees inherently parallelisable
Spring Reactor
Reactive Mongo
public interface QuoteMongoReactiveRepository
extends ReactiveCrudRepository<Quote, String>
{
}
Reactive Rest
@GetMapping("/quotes-reactive")
public Flux<Quote> getQuoteFlux() {
return quoteMongoReactiveRepository.findAll();
}
Angular
quotes: Quote[] = new Array();
url: string = 'http://localhost:8080/quotes-reactive';
getQuoteStream(page?: number, size?: number): Observable<Array<Quote>> {
this.quotes = new Array();
return Observable.create((observer) => {
let url = this.url;
let eventSource = new EventSource(url);
eventSource.onmessage = (event) => {
console.debug('Received event: ', event);
let json = JSON.parse(event.data);
this.quotes.push(new Quote(json['id'], json['book'], json['content']));
observer.next(this.quotes);
};
eventSource.onerror = (error) => observer.error('EventSource error: ' + error);
});
}
Angular
quotes: Quote[] = new Array();
url: string = 'http://localhost:8080/quotes-reactive';
getQuoteStream(page?: number, size?: number): Observable<Array<Quote>> {
this.quotes = new Array();
return Observable.create((observer) => {
let url = this.url;
let eventSource = new EventSource(url);
eventSource.onmessage = (event) => {
console.debug('Received event: ', event);
let json = JSON.parse(event.data);
this.quotes.push(new Quote(json['id'], json['book'], json['content']));
observer.next(this.quotes);
};
eventSource.onerror = (error) => observer.error('EventSource error: ' + error);
});
}
Demo Time
How do you test?
• curl -H "Accept: text/event-stream" http://localhost:8080/quotes-reactive
• Spring WebClient
• Spring WebTestClient
• Postman? Soapui? Browser?
Thoughts on Reactive Spring
• Pros
• Safer concurrency
• scale with a small, fixed number of threads and less
memory.
• makes applications more resilient under load because
they scale in a more predictable way
• Baked into Spring
• Java 10 Oracle Drivers Planned
Thoughts on Reactive Spring
• Cons
• Debugging complexity
• Steeeeeeep learning curve
• Do we understand Blocking?
• “it doesn’t matter if you use a Reactive Web approach in
the backend, it won’t be really reactive and non-blocking
unless your client is able to handle it as well”
Finally
• Source - https://github.com/roryp/full-reactive-stack
• Resources
• Project Reactor Site - https://projectreactor.io/
• Conal’s original paper https://github.com/conal/talk-2015-essence-and-
origins-of-frp

More Related Content

What's hot

Retrofit library for android
Retrofit library for androidRetrofit library for android
Retrofit library for androidInnovationM
 
SignalR: Above & Beyond Chat
SignalR: Above & Beyond ChatSignalR: Above & Beyond Chat
SignalR: Above & Beyond ChatDavid Pine
 
Inside asp.net mvc framework
Inside asp.net mvc frameworkInside asp.net mvc framework
Inside asp.net mvc frameworkCiklum Ukraine
 
Inside ASP.NET MVC framework
Inside ASP.NET MVC frameworkInside ASP.NET MVC framework
Inside ASP.NET MVC frameworkCiklum Ukraine
 
Full-Stack Reactive with Spring WebFlux + Angular - Oracle Code One 2018
Full-Stack Reactive with Spring WebFlux + Angular - Oracle Code One 2018Full-Stack Reactive with Spring WebFlux + Angular - Oracle Code One 2018
Full-Stack Reactive with Spring WebFlux + Angular - Oracle Code One 2018Loiane Groner
 
JavaOne 2013: Java 8 - The Good Parts
JavaOne 2013: Java 8 - The Good PartsJavaOne 2013: Java 8 - The Good Parts
JavaOne 2013: Java 8 - The Good PartsKonrad Malawski
 
Serverless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applicationsServerless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applicationsLoiane Groner
 
Reactive Programming on Android - RxAndroid - RxJava
Reactive Programming on Android - RxAndroid - RxJavaReactive Programming on Android - RxAndroid - RxJava
Reactive Programming on Android - RxAndroid - RxJavaAli Muzaffar
 
Creating custom transformer
Creating custom transformerCreating custom transformer
Creating custom transformerRahul Kumar
 
activity_and_fragment_may_2020_lakopi
activity_and_fragment_may_2020_lakopiactivity_and_fragment_may_2020_lakopi
activity_and_fragment_may_2020_lakopiToru Wonyoung Choi
 
Reflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond SmalltakReflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond SmalltakMarcus Denker
 
Full-Stack Reativo com Spring WebFlux + Angular - FiqueEmCasaConf
Full-Stack Reativo com Spring WebFlux + Angular - FiqueEmCasaConfFull-Stack Reativo com Spring WebFlux + Angular - FiqueEmCasaConf
Full-Stack Reativo com Spring WebFlux + Angular - FiqueEmCasaConfLoiane Groner
 
Creating custom aggregator
Creating custom aggregatorCreating custom aggregator
Creating custom aggregatorRahul Kumar
 
Reactive Programming in Java 8 with Rx-Java
Reactive Programming in Java 8 with Rx-JavaReactive Programming in Java 8 with Rx-Java
Reactive Programming in Java 8 with Rx-JavaKasun Indrasiri
 
What's new in React
What's new in ReactWhat's new in React
What's new in Reactsabativi
 
Getting into the flow building applications with reactive streams
Getting into the flow building applications with reactive streamsGetting into the flow building applications with reactive streams
Getting into the flow building applications with reactive streamsTim van Eijndhoven
 
The Mayans Lost Guide to RxJava on Android
The Mayans Lost Guide to RxJava on AndroidThe Mayans Lost Guide to RxJava on Android
The Mayans Lost Guide to RxJava on AndroidFernando Cejas
 
Functional Vaadin talk at OSCON 2014
Functional Vaadin talk at OSCON 2014Functional Vaadin talk at OSCON 2014
Functional Vaadin talk at OSCON 2014hezamu
 

What's hot (20)

Retrofit library for android
Retrofit library for androidRetrofit library for android
Retrofit library for android
 
SignalR: Above & Beyond Chat
SignalR: Above & Beyond ChatSignalR: Above & Beyond Chat
SignalR: Above & Beyond Chat
 
Inside asp.net mvc framework
Inside asp.net mvc frameworkInside asp.net mvc framework
Inside asp.net mvc framework
 
Inside ASP.NET MVC framework
Inside ASP.NET MVC frameworkInside ASP.NET MVC framework
Inside ASP.NET MVC framework
 
RxJava@Android
RxJava@AndroidRxJava@Android
RxJava@Android
 
Full-Stack Reactive with Spring WebFlux + Angular - Oracle Code One 2018
Full-Stack Reactive with Spring WebFlux + Angular - Oracle Code One 2018Full-Stack Reactive with Spring WebFlux + Angular - Oracle Code One 2018
Full-Stack Reactive with Spring WebFlux + Angular - Oracle Code One 2018
 
JavaOne 2013: Java 8 - The Good Parts
JavaOne 2013: Java 8 - The Good PartsJavaOne 2013: Java 8 - The Good Parts
JavaOne 2013: Java 8 - The Good Parts
 
Serverless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applicationsServerless Angular, Material, Firebase and Google Cloud applications
Serverless Angular, Material, Firebase and Google Cloud applications
 
Reactive Programming on Android - RxAndroid - RxJava
Reactive Programming on Android - RxAndroid - RxJavaReactive Programming on Android - RxAndroid - RxJava
Reactive Programming on Android - RxAndroid - RxJava
 
Creating custom transformer
Creating custom transformerCreating custom transformer
Creating custom transformer
 
activity_and_fragment_may_2020_lakopi
activity_and_fragment_may_2020_lakopiactivity_and_fragment_may_2020_lakopi
activity_and_fragment_may_2020_lakopi
 
JavaScript Functions
JavaScript FunctionsJavaScript Functions
JavaScript Functions
 
Reflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond SmalltakReflection in Pharo: Beyond Smalltak
Reflection in Pharo: Beyond Smalltak
 
Full-Stack Reativo com Spring WebFlux + Angular - FiqueEmCasaConf
Full-Stack Reativo com Spring WebFlux + Angular - FiqueEmCasaConfFull-Stack Reativo com Spring WebFlux + Angular - FiqueEmCasaConf
Full-Stack Reativo com Spring WebFlux + Angular - FiqueEmCasaConf
 
Creating custom aggregator
Creating custom aggregatorCreating custom aggregator
Creating custom aggregator
 
Reactive Programming in Java 8 with Rx-Java
Reactive Programming in Java 8 with Rx-JavaReactive Programming in Java 8 with Rx-Java
Reactive Programming in Java 8 with Rx-Java
 
What's new in React
What's new in ReactWhat's new in React
What's new in React
 
Getting into the flow building applications with reactive streams
Getting into the flow building applications with reactive streamsGetting into the flow building applications with reactive streams
Getting into the flow building applications with reactive streams
 
The Mayans Lost Guide to RxJava on Android
The Mayans Lost Guide to RxJava on AndroidThe Mayans Lost Guide to RxJava on Android
The Mayans Lost Guide to RxJava on Android
 
Functional Vaadin talk at OSCON 2014
Functional Vaadin talk at OSCON 2014Functional Vaadin talk at OSCON 2014
Functional Vaadin talk at OSCON 2014
 

Similar to Functional Reactive Endpoints using Spring 5

Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaRick Warren
 
Inside Logic Apps
Inside Logic AppsInside Logic Apps
Inside Logic AppsBizTalk360
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsJeff Durta
 
Sharding and Load Balancing in Scala - Twitter's Finagle
Sharding and Load Balancing in Scala - Twitter's FinagleSharding and Load Balancing in Scala - Twitter's Finagle
Sharding and Load Balancing in Scala - Twitter's FinagleGeoff Ballinger
 
Reactive java - Reactive Programming + RxJava
Reactive java - Reactive Programming + RxJavaReactive java - Reactive Programming + RxJava
Reactive java - Reactive Programming + RxJavaNexThoughts Technologies
 
Reactive, component 그리고 angular2
Reactive, component 그리고  angular2Reactive, component 그리고  angular2
Reactive, component 그리고 angular2Jeado Ko
 
Azure Durable Functions (2019-04-27)
Azure Durable Functions (2019-04-27)Azure Durable Functions (2019-04-27)
Azure Durable Functions (2019-04-27)Paco de la Cruz
 
RxJS - The Reactive extensions for JavaScript
RxJS - The Reactive extensions for JavaScriptRxJS - The Reactive extensions for JavaScript
RxJS - The Reactive extensions for JavaScriptViliam Elischer
 
Reactive Programming in Java and Spring Framework 5
Reactive Programming in Java and Spring Framework 5Reactive Programming in Java and Spring Framework 5
Reactive Programming in Java and Spring Framework 5Richard Langlois P. Eng.
 
What is new in java 8 concurrency
What is new in java 8 concurrencyWhat is new in java 8 concurrency
What is new in java 8 concurrencykshanth2101
 
react-slides.pdf gives information about react library
react-slides.pdf gives information about react libraryreact-slides.pdf gives information about react library
react-slides.pdf gives information about react libraryjanet736113
 
Azure Durable Functions (2019-03-30)
Azure Durable Functions (2019-03-30) Azure Durable Functions (2019-03-30)
Azure Durable Functions (2019-03-30) Paco de la Cruz
 
ReactiveCocoa in Practice
ReactiveCocoa in PracticeReactiveCocoa in Practice
ReactiveCocoa in PracticeOutware Mobile
 
Intro To Spring Python
Intro To Spring PythonIntro To Spring Python
Intro To Spring Pythongturnquist
 
How to perform debounce in react
How to perform debounce in reactHow to perform debounce in react
How to perform debounce in reactBOSC Tech Labs
 
"Service Worker: Let Your Web App Feel Like a Native "
"Service Worker: Let Your Web App Feel Like a Native ""Service Worker: Let Your Web App Feel Like a Native "
"Service Worker: Let Your Web App Feel Like a Native "FDConf
 
Azure Durable Functions (2018-06-13)
Azure Durable Functions (2018-06-13)Azure Durable Functions (2018-06-13)
Azure Durable Functions (2018-06-13)Paco de la Cruz
 
Declarative presentations UIKonf
Declarative presentations UIKonfDeclarative presentations UIKonf
Declarative presentations UIKonfNataliya Patsovska
 

Similar to Functional Reactive Endpoints using Spring 5 (20)

Building Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJavaBuilding Scalable Stateless Applications with RxJava
Building Scalable Stateless Applications with RxJava
 
Inside Logic Apps
Inside Logic AppsInside Logic Apps
Inside Logic Apps
 
Adding a modern twist to legacy web applications
Adding a modern twist to legacy web applicationsAdding a modern twist to legacy web applications
Adding a modern twist to legacy web applications
 
Sharding and Load Balancing in Scala - Twitter's Finagle
Sharding and Load Balancing in Scala - Twitter's FinagleSharding and Load Balancing in Scala - Twitter's Finagle
Sharding and Load Balancing in Scala - Twitter's Finagle
 
Reactive java - Reactive Programming + RxJava
Reactive java - Reactive Programming + RxJavaReactive java - Reactive Programming + RxJava
Reactive java - Reactive Programming + RxJava
 
react-slides.pptx
react-slides.pptxreact-slides.pptx
react-slides.pptx
 
Reactive, component 그리고 angular2
Reactive, component 그리고  angular2Reactive, component 그리고  angular2
Reactive, component 그리고 angular2
 
Azure Durable Functions (2019-04-27)
Azure Durable Functions (2019-04-27)Azure Durable Functions (2019-04-27)
Azure Durable Functions (2019-04-27)
 
RxJS - The Reactive extensions for JavaScript
RxJS - The Reactive extensions for JavaScriptRxJS - The Reactive extensions for JavaScript
RxJS - The Reactive extensions for JavaScript
 
Reactive Programming in Java and Spring Framework 5
Reactive Programming in Java and Spring Framework 5Reactive Programming in Java and Spring Framework 5
Reactive Programming in Java and Spring Framework 5
 
What is new in java 8 concurrency
What is new in java 8 concurrencyWhat is new in java 8 concurrency
What is new in java 8 concurrency
 
react-slides.pdf
react-slides.pdfreact-slides.pdf
react-slides.pdf
 
react-slides.pdf gives information about react library
react-slides.pdf gives information about react libraryreact-slides.pdf gives information about react library
react-slides.pdf gives information about react library
 
Azure Durable Functions (2019-03-30)
Azure Durable Functions (2019-03-30) Azure Durable Functions (2019-03-30)
Azure Durable Functions (2019-03-30)
 
ReactiveCocoa in Practice
ReactiveCocoa in PracticeReactiveCocoa in Practice
ReactiveCocoa in Practice
 
Intro To Spring Python
Intro To Spring PythonIntro To Spring Python
Intro To Spring Python
 
How to perform debounce in react
How to perform debounce in reactHow to perform debounce in react
How to perform debounce in react
 
"Service Worker: Let Your Web App Feel Like a Native "
"Service Worker: Let Your Web App Feel Like a Native ""Service Worker: Let Your Web App Feel Like a Native "
"Service Worker: Let Your Web App Feel Like a Native "
 
Azure Durable Functions (2018-06-13)
Azure Durable Functions (2018-06-13)Azure Durable Functions (2018-06-13)
Azure Durable Functions (2018-06-13)
 
Declarative presentations UIKonf
Declarative presentations UIKonfDeclarative presentations UIKonf
Declarative presentations UIKonf
 

More from Rory Preddy

Programming for accessibility
Programming for accessibilityProgramming for accessibility
Programming for accessibilityRory Preddy
 
Whats new in .net for 2019
Whats new in .net for 2019Whats new in .net for 2019
Whats new in .net for 2019Rory Preddy
 
Whats new in .NET for 2019
Whats new in .NET for 2019Whats new in .NET for 2019
Whats new in .NET for 2019Rory Preddy
 
Getting started with Firebase
Getting started with FirebaseGetting started with Firebase
Getting started with FirebaseRory Preddy
 
Whats new in Java 9,10,11,12
Whats new in Java 9,10,11,12Whats new in Java 9,10,11,12
Whats new in Java 9,10,11,12Rory Preddy
 
AWS for Java Developers workshop
AWS for Java Developers workshopAWS for Java Developers workshop
AWS for Java Developers workshopRory Preddy
 
Java 2018 certifications
Java 2018 certificationsJava 2018 certifications
Java 2018 certificationsRory Preddy
 
AWS Transcribe and Comprehend
AWS Transcribe and ComprehendAWS Transcribe and Comprehend
AWS Transcribe and ComprehendRory Preddy
 
BDD with Mockito
BDD with MockitoBDD with Mockito
BDD with MockitoRory Preddy
 
Up and Running with Kubernetes
Up and Running with KubernetesUp and Running with Kubernetes
Up and Running with KubernetesRory Preddy
 
AWS and Serverless with Alexa
AWS and Serverless with AlexaAWS and Serverless with Alexa
AWS and Serverless with AlexaRory Preddy
 
AWS for the Java Developer
AWS for the Java DeveloperAWS for the Java Developer
AWS for the Java DeveloperRory Preddy
 
BDD - Keep love alive
BDD - Keep love aliveBDD - Keep love alive
BDD - Keep love aliveRory Preddy
 

More from Rory Preddy (19)

Programming for accessibility
Programming for accessibilityProgramming for accessibility
Programming for accessibility
 
Whats new in .net for 2019
Whats new in .net for 2019Whats new in .net for 2019
Whats new in .net for 2019
 
Whats new in .NET for 2019
Whats new in .NET for 2019Whats new in .NET for 2019
Whats new in .NET for 2019
 
Getting started with Firebase
Getting started with FirebaseGetting started with Firebase
Getting started with Firebase
 
Whats new in Java 9,10,11,12
Whats new in Java 9,10,11,12Whats new in Java 9,10,11,12
Whats new in Java 9,10,11,12
 
AWS for Java Developers workshop
AWS for Java Developers workshopAWS for Java Developers workshop
AWS for Java Developers workshop
 
Java modules
Java modulesJava modules
Java modules
 
Java 2018 certifications
Java 2018 certificationsJava 2018 certifications
Java 2018 certifications
 
AWS Transcribe and Comprehend
AWS Transcribe and ComprehendAWS Transcribe and Comprehend
AWS Transcribe and Comprehend
 
BDD with Mockito
BDD with MockitoBDD with Mockito
BDD with Mockito
 
Up and Running with Kubernetes
Up and Running with KubernetesUp and Running with Kubernetes
Up and Running with Kubernetes
 
Dockercompose
DockercomposeDockercompose
Dockercompose
 
AWS and Serverless with Alexa
AWS and Serverless with AlexaAWS and Serverless with Alexa
AWS and Serverless with Alexa
 
Nashorn
NashornNashorn
Nashorn
 
AWS for the Java Developer
AWS for the Java DeveloperAWS for the Java Developer
AWS for the Java Developer
 
Vs java (1)
Vs java (1)Vs java (1)
Vs java (1)
 
Polyglot
PolyglotPolyglot
Polyglot
 
BDD - Keep love alive
BDD - Keep love aliveBDD - Keep love alive
BDD - Keep love alive
 
Kotlin
KotlinKotlin
Kotlin
 

Recently uploaded

buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutionsmonugehlot87
 
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
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number SystemsJheuzeDellosa
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackVICTOR MAESTRE RAMIREZ
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureDinusha Kumarasiri
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmSujith Sukumaran
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfkalichargn70th171
 
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.
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWave PLM
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...aditisharan08
 
What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?Watsoo Telematics
 
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
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataBradBedford3
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxTier1 app
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityNeo4j
 
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
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyFrank van der Linden
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - InfographicHr365.us smith
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...stazi3110
 

Recently uploaded (20)

buds n tech IT solutions
buds n  tech IT                solutionsbuds n  tech IT                solutions
buds n tech IT solutions
 
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
 
What is Binary Language? Computer Number Systems
What is Binary Language?  Computer Number SystemsWhat is Binary Language?  Computer Number Systems
What is Binary Language? Computer Number Systems
 
Cloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStackCloud Management Software Platforms: OpenStack
Cloud Management Software Platforms: OpenStack
 
Implementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with AzureImplementing Zero Trust strategy with Azure
Implementing Zero Trust strategy with Azure
 
Intelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalmIntelligent Home Wi-Fi Solutions | ThinkPalm
Intelligent Home Wi-Fi Solutions | ThinkPalm
 
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdfThe Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
The Essentials of Digital Experience Monitoring_ A Comprehensive Guide.pdf
 
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 ...
 
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...Call Girls In Mukherjee Nagar 📱  9999965857  🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
Call Girls In Mukherjee Nagar 📱 9999965857 🤩 Delhi 🫦 HOT AND SEXY VVIP 🍎 SE...
 
What is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need ItWhat is Fashion PLM and Why Do You Need It
What is Fashion PLM and Why Do You Need It
 
Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...Unit 1.1 Excite Part 1, class 9, cbse...
Unit 1.1 Excite Part 1, class 9, cbse...
 
What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?What are the features of Vehicle Tracking System?
What are the features of Vehicle Tracking System?
 
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...
 
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer DataAdobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
Adobe Marketo Engage Deep Dives: Using Webhooks to Transfer Data
 
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptxKnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
KnowAPIs-UnknownPerf-jaxMainz-2024 (1).pptx
 
EY_Graph Database Powered Sustainability
EY_Graph Database Powered SustainabilityEY_Graph Database Powered Sustainability
EY_Graph Database Powered Sustainability
 
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...
 
Engage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The UglyEngage Usergroup 2024 - The Good The Bad_The Ugly
Engage Usergroup 2024 - The Good The Bad_The Ugly
 
Asset Management Software - Infographic
Asset Management Software - InfographicAsset Management Software - Infographic
Asset Management Software - Infographic
 
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
Building a General PDE Solving Framework with Symbolic-Numeric Scientific Mac...
 

Functional Reactive Endpoints using Spring 5

  • 1. Reactive Spring 5 (AKA Functional Reactive Programming with Spring)
  • 2. Why I chose this talk?
  • 3. A definition Reactive Programming is all about non-blocking applications that are asynchronous and event-driven and require a small number of threads to scale -Spring.io
  • 4. What is Reactive Programming? • Observer • Interface to notify an object that the next item in a sequence it is watching it is available • Streams • Controlled exchange of stream data across Applications • Back-pressure • control the flow of a Stream between producer and consumer
  • 5.
  • 6. What is Functional Reactive Programming? Conal Elliot defined FRP back in 1998, in his paper "Functional Reactive Animation”: • “FRP expressions describe entire evolutions of values over time, representing these evolutions directly as first-class values
  • 7. What is Functional reactive programming? • Compositionality • Being able to compose functions • Immutability • Guarantees inherently parallelisable
  • 8.
  • 10. Reactive Mongo public interface QuoteMongoReactiveRepository extends ReactiveCrudRepository<Quote, String> { }
  • 11.
  • 12. Reactive Rest @GetMapping("/quotes-reactive") public Flux<Quote> getQuoteFlux() { return quoteMongoReactiveRepository.findAll(); }
  • 13. Angular quotes: Quote[] = new Array(); url: string = 'http://localhost:8080/quotes-reactive'; getQuoteStream(page?: number, size?: number): Observable<Array<Quote>> { this.quotes = new Array(); return Observable.create((observer) => { let url = this.url; let eventSource = new EventSource(url); eventSource.onmessage = (event) => { console.debug('Received event: ', event); let json = JSON.parse(event.data); this.quotes.push(new Quote(json['id'], json['book'], json['content'])); observer.next(this.quotes); }; eventSource.onerror = (error) => observer.error('EventSource error: ' + error); }); }
  • 14. Angular quotes: Quote[] = new Array(); url: string = 'http://localhost:8080/quotes-reactive'; getQuoteStream(page?: number, size?: number): Observable<Array<Quote>> { this.quotes = new Array(); return Observable.create((observer) => { let url = this.url; let eventSource = new EventSource(url); eventSource.onmessage = (event) => { console.debug('Received event: ', event); let json = JSON.parse(event.data); this.quotes.push(new Quote(json['id'], json['book'], json['content'])); observer.next(this.quotes); }; eventSource.onerror = (error) => observer.error('EventSource error: ' + error); }); }
  • 16. How do you test? • curl -H "Accept: text/event-stream" http://localhost:8080/quotes-reactive • Spring WebClient • Spring WebTestClient • Postman? Soapui? Browser?
  • 17. Thoughts on Reactive Spring • Pros • Safer concurrency • scale with a small, fixed number of threads and less memory. • makes applications more resilient under load because they scale in a more predictable way • Baked into Spring • Java 10 Oracle Drivers Planned
  • 18. Thoughts on Reactive Spring • Cons • Debugging complexity • Steeeeeeep learning curve • Do we understand Blocking? • “it doesn’t matter if you use a Reactive Web approach in the backend, it won’t be really reactive and non-blocking unless your client is able to handle it as well”
  • 19. Finally • Source - https://github.com/roryp/full-reactive-stack • Resources • Project Reactor Site - https://projectreactor.io/ • Conal’s original paper https://github.com/conal/talk-2015-essence-and- origins-of-frp