SlideShare a Scribd company logo
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
Functional Reactive Endpoints using Spring 5
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
Functional Reactive Endpoints using Spring 5
Spring Reactor
Reactive Mongo
public interface QuoteMongoReactiveRepository
extends ReactiveCrudRepository<Quote, String>
{
}
Functional Reactive Endpoints using Spring 5
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

PPTX
Top 10 RxJs Operators in Angular
PDF
FullStack Reativo com Spring WebFlux + Angular
PPTX
Introduction to RxJava on Android
PPTX
Pure functions and usage in Angular
PDF
Angular & RXJS: examples and use cases
PDF
Actor Model pattern for concurrency
PDF
Using ReasonML For Your Next JavaScript Project
PPTX
Code craftsmanship saturdays second session
Top 10 RxJs Operators in Angular
FullStack Reativo com Spring WebFlux + Angular
Introduction to RxJava on Android
Pure functions and usage in Angular
Angular & RXJS: examples and use cases
Actor Model pattern for concurrency
Using ReasonML For Your Next JavaScript Project
Code craftsmanship saturdays second session

What's hot (20)

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

Similar to Functional Reactive Endpoints using Spring 5 (20)

PDF
Building Scalable Stateless Applications with RxJava
PPTX
Inside Logic Apps
PPTX
Adding a modern twist to legacy web applications
PPTX
Sharding and Load Balancing in Scala - Twitter's Finagle
PPTX
react-slidlkjfl;kj;dlkjopidfjhopijgpoerjpofjiwoepifjopweifjepoies.pptx
PPTX
TRAINING pptt efwoiefo weoifjoiewjfoifjow.pptx
PDF
Reactive java - Reactive Programming + RxJava
PPTX
react-slides.pptx
PDF
Reactive, component 그리고 angular2
PDF
Azure Durable Functions (2019-04-27)
PDF
RxJS - The Reactive extensions for JavaScript
PDF
Reactive Programming in Java and Spring Framework 5
PDF
What is new in java 8 concurrency
PDF
react-slides.pdf
PDF
react-slides.pdf gives information about react library
PDF
Azure Durable Functions (2019-03-30)
PDF
ReactiveCocoa in Practice
ODP
Intro To Spring Python
PPTX
How to perform debounce in react
PDF
"Service Worker: Let Your Web App Feel Like a Native "
Building Scalable Stateless Applications with RxJava
Inside Logic Apps
Adding a modern twist to legacy web applications
Sharding and Load Balancing in Scala - Twitter's Finagle
react-slidlkjfl;kj;dlkjopidfjhopijgpoerjpofjiwoepifjopweifjepoies.pptx
TRAINING pptt efwoiefo weoifjoiewjfoifjow.pptx
Reactive java - Reactive Programming + RxJava
react-slides.pptx
Reactive, component 그리고 angular2
Azure Durable Functions (2019-04-27)
RxJS - The Reactive extensions for JavaScript
Reactive Programming in Java and Spring Framework 5
What is new in java 8 concurrency
react-slides.pdf
react-slides.pdf gives information about react library
Azure Durable Functions (2019-03-30)
ReactiveCocoa in Practice
Intro To Spring Python
How to perform debounce in react
"Service Worker: Let Your Web App Feel Like a Native "
Ad

More from Rory Preddy (19)

PPTX
Programming for accessibility
PPTX
Whats new in .net for 2019
PDF
Whats new in .NET for 2019
PDF
Getting started with Firebase
PDF
Whats new in Java 9,10,11,12
PDF
AWS for Java Developers workshop
PDF
Java modules
PDF
Java 2018 certifications
PPTX
AWS Transcribe and Comprehend
PPTX
BDD with Mockito
PPTX
Up and Running with Kubernetes
PPTX
Dockercompose
PPTX
AWS and Serverless with Alexa
PPTX
Nashorn
PPTX
AWS for the Java Developer
PPTX
Vs java (1)
PPTX
Polyglot
PPTX
BDD - Keep love alive
PPTX
Kotlin
Programming for accessibility
Whats new in .net for 2019
Whats new in .NET for 2019
Getting started with Firebase
Whats new in Java 9,10,11,12
AWS for Java Developers workshop
Java modules
Java 2018 certifications
AWS Transcribe and Comprehend
BDD with Mockito
Up and Running with Kubernetes
Dockercompose
AWS and Serverless with Alexa
Nashorn
AWS for the Java Developer
Vs java (1)
Polyglot
BDD - Keep love alive
Kotlin

Recently uploaded (20)

PPTX
Odoo POS Development Services by CandidRoot Solutions
PDF
Upgrade and Innovation Strategies for SAP ERP Customers
PDF
medical staffing services at VALiNTRY
PDF
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
PPTX
Essential Infomation Tech presentation.pptx
PPTX
Introduction to Artificial Intelligence
PPTX
Reimagine Home Health with the Power of Agentic AI​
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PDF
Digital Strategies for Manufacturing Companies
PDF
wealthsignaloriginal-com-DS-text-... (1).pdf
PDF
top salesforce developer skills in 2025.pdf
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
System and Network Administration Chapter 2
PDF
How to Migrate SBCGlobal Email to Yahoo Easily
PPTX
CHAPTER 2 - PM Management and IT Context
PDF
PTS Company Brochure 2025 (1).pdf.......
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
history of c programming in notes for students .pptx
PDF
Nekopoi APK 2025 free lastest update
Odoo POS Development Services by CandidRoot Solutions
Upgrade and Innovation Strategies for SAP ERP Customers
medical staffing services at VALiNTRY
Raksha Bandhan Grocery Pricing Trends in India 2025.pdf
Essential Infomation Tech presentation.pptx
Introduction to Artificial Intelligence
Reimagine Home Health with the Power of Agentic AI​
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
Digital Strategies for Manufacturing Companies
wealthsignaloriginal-com-DS-text-... (1).pdf
top salesforce developer skills in 2025.pdf
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Internet Downloader Manager (IDM) Crack 6.42 Build 41
System and Network Administration Chapter 2
How to Migrate SBCGlobal Email to Yahoo Easily
CHAPTER 2 - PM Management and IT Context
PTS Company Brochure 2025 (1).pdf.......
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
history of c programming in notes for students .pptx
Nekopoi APK 2025 free lastest update

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
  • 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
  • 10. Reactive Mongo public interface QuoteMongoReactiveRepository extends ReactiveCrudRepository<Quote, String> { }
  • 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