SlideShare a Scribd company logo
Reactive Microservices
And Spring 5
Jay Lee(jaylee@pivotal.io)
Senior Platform Architect
Jay Lee(이창재)
Senior Platform Architect
Reactive Streams
Reactive Programming in One Picture
Reactive Programming is paradigm oriented
around data flows and propagation of change
Reactive Microservice And Spring5
Reactive Streams is an initiative to provide a
standard for asynchronous stream processing
with non-blocking back pressure. This
encompasses efforts aimed at runtime
environments (JVM and JavaScript) as well as
network protocols.
- http://www.reactive-streams.org/
Asynchronous?
http://www.ibm.com/developerworks/library/l-async/figure4.gif
Asynchronous?
http://www.ibm.com/developerworks/library/l-async/figure5.gif
Reactive Streams is an initiative to provide a
standard for asynchronous stream processing
with non-blocking back pressure. This
encompasses efforts aimed at runtime
environments (JVM and JavaScript) as well as
network protocols.
- http://www.reactive-streams.org/
Publisher Subscriber
Stream Processing
Publisher Subscriber
Stream Processing
3msg/sec 1msg/sec
Publisher Subscriber
Stream Processing
3msg/sec 1msg/sec
Publisher Subscriber
Stream Processing
3msg/sec 1msg/sec
Publisher Subscriber
Stream Processing
3msg/sec 1msg/sec
Publisher Subscriber
Stream Processing With Back Pressure
3msg/sec 1msg/sec
Hey, I can only take 1msg/sec
Publisher Subscriber
Stream Processing With Back Pressure
1msg/sec 1msg/sec
Hey, I can only take 1msg/sec
Gotcha!!
Back Pressure in real world
Back Pressure in real world
Reactive Microservice And Spring5
Reactive Stream Implementation
Ÿ RxJavaReactiveStreams with RxJava 1.x 2.x
Ÿ Project Reactor
Ÿ Vert.x
Ÿ Akka Streams
Ÿ Slick
Ÿ …
Project Reactor
Journey of Project Reactor
2
2
2
Project Reactor
Project Reactor
Ÿ Reactive Streams Library for JVM
Ÿ Declarative operations similar to Java 8 Streams
Ÿ Flux and Mono reactive composable API types
Ÿ Compatible with RxJava,
Reactive Streams
http://javasampleapproach.com/java/java-9/java-9-flow-api-reactive-streams
Reactive Streams: Mono – sequence of 0..1Mono
Mono<String> emptyMono() {
return Mono.empty(); }
Mono<String> fooMono() {
return Mono.just("foo"); }
Mono<String> toUpperCase(Mono<String> mono) {
return mono.map(String::toUpperCase); }
Mono BasicMono Basic
Reactive Streams: Flux – sequence of 0..NFlux
Flux Basic
Flux<String> emptyFlux() {
return Flux.empty();}
Flux<String> fooBarFluxFromValues() {
return Flux.just("foo", "bar");}
Flux<String> fooBarFluxFromList() {
return Flux.fromIterable(Arrays.asList("foo", "bar")); }
Flux<String> toUpperCase(Flux<String> flux) {
return flux.flatMap(s -> Mono.just(s.toUpperCase())); }
Flux Basic
Spring 5
Spring 5 - Reactive Repository
public interface ReactivePersonRepository extends ReactiveCrudRepository<Person,
String> {
Flux<Person> findByLastname(Mono<String> lastname);
Mono<Person> findByFirstnameAndLastname(String firstname, String lastname);
}
@EnableReactiveMongoRepositories
public class AppConfig extends AbstractReactiveMongoConfiguration {
}
(Repository)
Ÿ MongoDB
Ÿ Cassandra
Ÿ Redis
Ÿ Couchbase
Spring 5 – Spring Data Compatible
Ÿ Oracle, MySQL
Ÿ A database access API for Java that does not block user
threads
Ÿ Target high throughput apps
From: JDBC Next by Douglas Surber (JavaOne 2016)
NonBlocking JDBC Access to Oracle,Mysql
public void trivialSelect(DataSource ds, List<Integer> result)
{
String sql = "select <<id>>, <<name>>, <<answer>> " + "from tab where answer = <<i target>>";
try (Connection conn = ds.getConnection()) {
conn.<List<Integer>>rowOperation(sql)
.set("target", 42, JdbcType.NUMERIC)
.rowAggregator( (ignore, row) -> {
result.add(row.get("id", Integer.class));
return null;
} )
.submit(); }}
NonBlocking JDBC Example
Spring 5 - Reactive Web Controller
@Controller
Public class UserController {
private final UserRepository userRepository;
public UserController(UserRepository userRepository) {
this.userRepository = userRepository; }
@GetMapping(“/users/{id}”)
public Mono<User> getUser(@PathVariable Long id) {
return this.userRepository.findOne(id);}
@PostMapping(“/users”)
public Mono<Void> addUser(@RequestBody User user) {
return this.userRepository.save(user);}
}
(Controller) - (Repository)
Spring 5 - Reactive Web Framework
public interface ReactiveHttpInputMessage extends HttpMessage {
Flux<DataBuffer> getBody();
}
public interface ReactiveHttpOutputMessage extends HttpMessage {
Mono<Void> writeWith(Publisher<DataBuffer> body);
}
(Framework) - (Controller) - (Repository)
Spring 5 – Reactive HTTP Server
Ÿ Servlet 3.1 Bridge
Ÿ Undertow in spring-web
Ÿ Reactor Netty
Ÿ RxNetty
Ÿ Reactive Stream Bridge to Tomcat and Jetty
(HTTP Server) - (Framework) - (Controller) - (Repository)
Observable<User> fromFluxToObservable(Flux<User> flux) {
return Observable.fromPublisher(flux);
}
Flux<User> fromObservableToFlux(Observable<User> observable) {
return Flux.from(observable.toFlowable(BackpressureStrategy.BUFFER));
}
RxJava Observable and Reactor
CompletableFuture<User> fromMonoToCompletableFuture(Mono<User>
mono) {
return mono.toFuture();
}
Mono<User> fromCompletableFutureToMono(CompletableFuture<User>
future) {
return Mono.fromFuture(future);
}
Mono and CompletableFuture
Summary
• Spring 5.0 GA 곧 출시!!
Ÿ Reactive Streams
Ÿ Microservices and Reactive Streams
Ÿ Spring 5.0 GA – Jul 27, 2017
Ÿ Being adopted for Boot, Security, Data, Cloud, Integration,
etc
Summary
Reactive Microservice And Spring5

More Related Content

What's hot (20)

PPTX
Going Reactive with Spring 5
Drazen Nikolic
 
PDF
JDBC Next: A New Asynchronous API for Connecting to a Database
Yolande Poirier
 
PDF
Reactive database access with Slick3
takezoe
 
PDF
rx-java-presentation
Mateusz Bukowicz
 
PDF
Dropwizard Spring - the perfect Java REST server stack
Jacek Furmankiewicz
 
PDF
Reactive Applications with Apache Pulsar and Spring Boot
VMware Tanzu
 
PDF
점진적인 레거시 웹 애플리케이션 개선 과정
Arawn Park
 
PDF
Spring Framework 4.0 - The Next Generation - Soft-Shake 2013
Sam Brannen
 
PDF
Database migrations with Flyway and Liquibase
Lars Östling
 
PDF
Power tools in Java
DPC Consulting Ltd
 
PDF
From Spring Framework 5.3 to 6.0
VMware Tanzu
 
PDF
Java 9 and Beyond
Mayank Patel
 
PPTX
Flyway: The agile database migration framework for Java
Axel Fontaine
 
PDF
Microservices for Systematic Profiling and Monitoring of the Refactoring
Alexander Mazurov
 
PDF
Greach 2014 - Road to Grails 3.0
graemerocher
 
PPTX
Airflow at WePay
Chris Riccomini
 
PDF
Spring framework 4.x
Arawn Park
 
PPTX
Redesigning Apache Flink's Distributed Architecture @ Flink Forward 2017
Till Rohrmann
 
PDF
Apache Airflow in the Cloud: Programmatically orchestrating workloads with Py...
Kaxil Naik
 
Going Reactive with Spring 5
Drazen Nikolic
 
JDBC Next: A New Asynchronous API for Connecting to a Database
Yolande Poirier
 
Reactive database access with Slick3
takezoe
 
rx-java-presentation
Mateusz Bukowicz
 
Dropwizard Spring - the perfect Java REST server stack
Jacek Furmankiewicz
 
Reactive Applications with Apache Pulsar and Spring Boot
VMware Tanzu
 
점진적인 레거시 웹 애플리케이션 개선 과정
Arawn Park
 
Spring Framework 4.0 - The Next Generation - Soft-Shake 2013
Sam Brannen
 
Database migrations with Flyway and Liquibase
Lars Östling
 
Power tools in Java
DPC Consulting Ltd
 
From Spring Framework 5.3 to 6.0
VMware Tanzu
 
Java 9 and Beyond
Mayank Patel
 
Flyway: The agile database migration framework for Java
Axel Fontaine
 
Microservices for Systematic Profiling and Monitoring of the Refactoring
Alexander Mazurov
 
Greach 2014 - Road to Grails 3.0
graemerocher
 
Airflow at WePay
Chris Riccomini
 
Spring framework 4.x
Arawn Park
 
Redesigning Apache Flink's Distributed Architecture @ Flink Forward 2017
Till Rohrmann
 
Apache Airflow in the Cloud: Programmatically orchestrating workloads with Py...
Kaxil Naik
 

Similar to Reactive Microservice And Spring5 (20)

PDF
Spring 5 Project Reactor
Geoffrey Filippi
 
PDF
REACTIVE A New Hope!
Alberto Salazar
 
PPTX
Going Reactive with Relational Databases
Ivaylo Pashov
 
PPTX
Spring reactor
Bhargav Surimenu
 
PDF
Full Steam Ahead, R2DBC!
VMware Tanzu
 
PDF
Infinite Streams, Hot Fluxes, Live Queries and Tailable Cursors
Brian Matthews
 
PPTX
Introduction to R2DBC
Rob Hedgpeth
 
PDF
End-to-End Reactive Data Access Using R2DBC with RSocket and Proteus
VMware Tanzu
 
PDF
Under the Hood of Reactive Data Access (2/2)
VMware Tanzu
 
PDF
Openbar 12 - Leuven - From reactive programming to reactive architecture
Openbar
 
PDF
Introducing the R2DBC async Java connector
MariaDB plc
 
PDF
An introduction to Reactive applications, Reactive Streams, and options for t...
Steve Pember
 
PDF
CloudLand - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, and...
Juarez Junior
 
PDF
Sck spring-reactive
Somkiat Puisungnoen
 
PDF
Spring Framework 5: History and Reactive features
Aliaksei Zhynhiarouski
 
PDF
Reactive systems
Naresh Chintalcheru
 
PPTX
Introduction to Spring Reactor
DrSimoneDiCola
 
PPTX
Spring Webflux
Carlos E. Salazar
 
PDF
DWX23 - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, and STO...
Juarez Junior
 
PDF
Multi-service reactive streams using Spring, Reactor, RSocket
Stéphane Maldini
 
Spring 5 Project Reactor
Geoffrey Filippi
 
REACTIVE A New Hope!
Alberto Salazar
 
Going Reactive with Relational Databases
Ivaylo Pashov
 
Spring reactor
Bhargav Surimenu
 
Full Steam Ahead, R2DBC!
VMware Tanzu
 
Infinite Streams, Hot Fluxes, Live Queries and Tailable Cursors
Brian Matthews
 
Introduction to R2DBC
Rob Hedgpeth
 
End-to-End Reactive Data Access Using R2DBC with RSocket and Proteus
VMware Tanzu
 
Under the Hood of Reactive Data Access (2/2)
VMware Tanzu
 
Openbar 12 - Leuven - From reactive programming to reactive architecture
Openbar
 
Introducing the R2DBC async Java connector
MariaDB plc
 
An introduction to Reactive applications, Reactive Streams, and options for t...
Steve Pember
 
CloudLand - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, and...
Juarez Junior
 
Sck spring-reactive
Somkiat Puisungnoen
 
Spring Framework 5: History and Reactive features
Aliaksei Zhynhiarouski
 
Reactive systems
Naresh Chintalcheru
 
Introduction to Spring Reactor
DrSimoneDiCola
 
Spring Webflux
Carlos E. Salazar
 
DWX23 - A High-Speed Data Ingestion Service in Java Using MQTT, AMQP, and STO...
Juarez Junior
 
Multi-service reactive streams using Spring, Reactor, RSocket
Stéphane Maldini
 
Ad

More from Jay Lee (10)

PDF
Spring on Kubernetes
Jay Lee
 
PDF
Knative And Pivotal Function As a Service
Jay Lee
 
PDF
Knative and Riff
Jay Lee
 
PDF
CF Korea Meetup - Spring Cloud Services
Jay Lee
 
PDF
SpringCamp 2016 - Apache Geode 와 Spring Data Gemfire
Jay Lee
 
PPTX
CF Korea Meetup - Gemfire on PCF
Jay Lee
 
PDF
JavaEE6 - 설계 차원의 단순성
Jay Lee
 
PDF
Java8 - Oracle Korea Magazine
Jay Lee
 
PPTX
Java EE7
Jay Lee
 
PDF
Java 8 & Beyond
Jay Lee
 
Spring on Kubernetes
Jay Lee
 
Knative And Pivotal Function As a Service
Jay Lee
 
Knative and Riff
Jay Lee
 
CF Korea Meetup - Spring Cloud Services
Jay Lee
 
SpringCamp 2016 - Apache Geode 와 Spring Data Gemfire
Jay Lee
 
CF Korea Meetup - Gemfire on PCF
Jay Lee
 
JavaEE6 - 설계 차원의 단순성
Jay Lee
 
Java8 - Oracle Korea Magazine
Jay Lee
 
Java EE7
Jay Lee
 
Java 8 & Beyond
Jay Lee
 
Ad

Recently uploaded (20)

PDF
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
PDF
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
PDF
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
PPTX
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
PDF
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
PPTX
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
PDF
Complete Network Protection with Real-Time Security
L4RGINDIA
 
PDF
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
PDF
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
PDF
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
PDF
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
PDF
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
PDF
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
PDF
Blockchain Transactions Explained For Everyone
CIFDAQ
 
PPTX
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
PDF
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
PDF
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
PDF
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
PDF
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 
LLMs.txt: Easily Control How AI Crawls Your Site
Keploy
 
Complete JavaScript Notes: From Basics to Advanced Concepts.pdf
haydendavispro
 
How Startups Are Growing Faster with App Developers in Australia.pdf
India App Developer
 
MSP360 Backup Scheduling and Retention Best Practices.pptx
MSP360
 
Predicting the unpredictable: re-engineering recommendation algorithms for fr...
Speck&Tech
 
UiPath Academic Alliance Educator Panels: Session 2 - Business Analyst Content
DianaGray10
 
Complete Network Protection with Real-Time Security
L4RGINDIA
 
CIFDAQ Weekly Market Wrap for 11th July 2025
CIFDAQ
 
NewMind AI Journal - Weekly Chronicles - July'25 Week II
NewMind AI
 
New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Transcript: New from BookNet Canada for 2025: BNC BiblioShare - Tech Forum 2025
BookNet Canada
 
Smart Air Quality Monitoring with Serrax AQM190 LITE
SERRAX TECHNOLOGIES LLP
 
Smart Trailers 2025 Update with History and Overview
Paul Menig
 
Building Resilience with Digital Twins : Lessons from Korea
SANGHEE SHIN
 
Blockchain Transactions Explained For Everyone
CIFDAQ
 
OpenID AuthZEN - Analyst Briefing July 2025
David Brossard
 
Achieving Consistent and Reliable AI Code Generation - Medusa AI
medusaaico
 
NewMind AI - Journal 100 Insights After The 100th Issue
NewMind AI
 
Why Orbit Edge Tech is a Top Next JS Development Company in 2025
mahendraalaska08
 
Fl Studio 24.2.2 Build 4597 Crack for Windows Free Download 2025
faizk77g
 

Reactive Microservice And Spring5