SlideShare a Scribd company logo
Modern app programming
with RxJava & Eclipse Vert.x
Who am I?
● Thomas Segismont
● tsegismont on GitHub, Twitter, Gmail, Freenode...
● Vert.x core team since August 2016
● At Red Hat since November 2012 (RHQ and Hawkular)
#RivieraDev @vertx_project
Expectations
● Goals
– Why is reactive programming important?
– What are RxJava and Vert.x?
– How can I combine them to build scalable, efficient and resilient
apps?
● Non goals
– In-depth study of RxJava or Vert.x
#RivieraDev @vertx_project
Back to the late 90s…
A hotel room booking engine
http://example.com
http://example.com
http://example.com
Such apps are mainstream today!
● Microservices
● API economy
#RivieraDev @vertx_project
Alexandre Duret-Lutz (CC BY-SA 2.0)
Event loop systems
Reactor pattern
Single
thread
New stuff?
● Browser (AJAX, #setTimeout)
● GUI
● Node.js
#RivieraDev @vertx_project
Event loop benefits
● Simple concurrency model
● Mechanical sympathy http://bit.ly/2cJMBsG
– Higher throughput
– Predictable latency
#RivieraDev @vertx_project
Vert.x
What is Vert.x
● A toolkit (lib)
● … to build polyglot (on the JVM)
– JS, Groovy, Ruby, Scala (3.4), Kotlin (3.4)
● … reactive systems
#RivieraDev @vertx_project
Demo
Damn simple verticle
Modern app programming with RxJava and Eclipse Vert.x
Multi-Reactor
#RivieraDev @vertx_project
Event Bus
● Nervous system of Vert.x
● Message passing style
● Different messaging paradigms:
– Point to point
– Publish/Subscribe
– Request/Reply
#RivieraDev @vertx_project
Running blocking code
● In the real world, most JVM libraries have blocking APIs
– JDBC
– io.File
– Your legacy libs
● With Vert.x you can interact with blocking parts easily
● You won’t throw away your code assets!
#RivieraDev @vertx_project
Modern app programming with RxJava and Eclipse Vert.x
Callback based (reactive imperative)
CALLBACK HELL !
RxJava
Data and events flows
● It is great at organizing transformation of data and coordination
of events
● It makes most sense when many sources of events are
involved (modern apps!)
#RivieraDev @vertx_project
Push based
Observable Observer
Subscription
● OnNext 0..∞
● Terminal event 0..1
– OnComplete
– OnError
#RivieraDev @vertx_project
Reactive pull backpressure
Observable Observer
Subscription
Request
#RivieraDev @vertx_project
Observable / Single / Completable
Zero One Many
Sync void T Iterable<T>
Async Completable Single<T> Observable<T>
#RivieraDev @vertx_project
Demo
Damn simple Rx Verticle
Music Store Demo
https://github.com/tsegismont/vertx-musicstore
http://example.com
http://example.com
http://example.com
https://coverartarchive.org/
Postgres
Couchbase
Vert.x RxJava
Vert.x
Web Client
HTTP
Vert.x
JDBC Client
Couchbase
RxJava driver
Event Bus Bridge
(WebSocket)
Vert.x
Local Cache
Observable#map
ReactiveX.io Creative Commons Attribution 3.0 License
Observable#map
private Single<JsonArray> findAlbums(SQLConnection sqlConnection, Long artistId) {
return sqlConnection.rxQueryStreamWithParams(findAlbumsByArtist, new JsonArray().add(artistId))
.flatMapObservable(SQLRowStream::toObservable)
.map(row -> new JsonObject().put("id", row.getLong(0)).put("title", row.getString(1)))
.collect(JsonArray::new, JsonArray::add)
.toSingle();
}
#RivieraDev @vertx_project
Observable#flatMap
ReactiveX.io Creative Commons Attribution 3.0 License
Single#flatMap
public void handle(RoutingContext rc) {
dbClient.rxGetConnection().flatMap(sqlConnection -> {
return findGenres(sqlConnection).doAfterTerminate(sqlConnection::close);
}).flatMap(genres -> {
rc.put("genres", genres);
return templateEngine.rxRender(rc, "templates/index");
}).subscribe(rc.response()::end, rc::fail);
}
#RivieraDev @vertx_project
Single#zip
ReactiveX.io Creative Commons Attribution 3.0 License
Single#zip
Single<JsonObject> as = findAlbum(sqlConnection, albumId);
Single<JsonArray> ts = findTracks(sqlConnection, albumId);
return Single.zip(as, ts, (album, tracks) -> {
Map<String, Object> data = new HashMap<>(2);
data.put("album", album);
data.put("tracks", tracks);
return data;
}).doAfterTerminate(sqlConnection::close);
#RivieraDev @vertx_project
Observable#observeOn
ReactiveX.io Creative Commons Attribution 3.0 License
Observable#observeOn
#RivieraDev @vertx_project
albumCommentsBucket.query(Query.parametrized(findRecentCommentsByAlbum, params))
.observeOn(RxHelper.scheduler(rc.vertx()))
.flatMap(AsyncQueryResult::rows)
.limit(5)
.collect(JsonArray::new, (jsonArray, row) -> jsonArray.add(new JsonObject(row.value().toMap())))
.toSingle()
.flatMap(data -> {
rc.put("comments", data);
return templateEngine.rxRender(rc, "templates/partials/album_comments");
}).subscribe(rc.response()::end, rc::fail);
#RivieraDev @vertx_project
http://red.ht/2pgMEoA
Thank you!
http://vertx.io
Come get your sticker!
#RivieraDev @vertx_project

More Related Content

PDF
RxJava - introduction & design
PDF
Reactive programming with Rxjava
PDF
Building ‘Bootiful’ microservices cloud
PPTX
Javantura v3 - ES6 – Future Is Now – Nenad Pečanac
PPTX
Introduction to Reactive Java
PDF
Introduction to Akka-Streams
PDF
Reactor in Action
PDF
Microservices with Netflix OSS & Spring Cloud - Arnaud Cogoluègnes
RxJava - introduction & design
Reactive programming with Rxjava
Building ‘Bootiful’ microservices cloud
Javantura v3 - ES6 – Future Is Now – Nenad Pečanac
Introduction to Reactive Java
Introduction to Akka-Streams
Reactor in Action
Microservices with Netflix OSS & Spring Cloud - Arnaud Cogoluègnes

What's hot (20)

PPTX
Asynchronous programming in ASP.NET
PDF
Event Machine
PPT
Reactive programming with examples
PDF
Microservices with Spring Cloud
PDF
Queick: A Simple Job Queue System for Python
PDF
Reactive Streams: Handling Data-Flow the Reactive Way
KEY
Concurrency in ruby
PDF
Spring Boot to Quarkus: A real app migration experience | DevNation Tech Talk
PDF
Spring Cloud and Netflix OSS overview v1
PDF
Performance measurement methodology — Maksym Pugach | Elixir Evening Club 3
PDF
Understanding and Extending Prometheus AlertManager
PPTX
Gabriele Provinciali/Gabriele Folchi/Luca Postacchini - Sviluppo con piattafo...
PPTX
Asynchronous Python with Twisted
PDF
WTF is Twisted?
PDF
Microservices with Netflix OSS and Spring Cloud - Dev Day Orange
PDF
Reactive Card Magic: Understanding Spring WebFlux and Project Reactor
PDF
Reactive programming with RxJava
PDF
Building Scalable Stateless Applications with RxJava
PDF
CDK Meetup: Rule the World through IaC
PDF
Kubernetes and Prometheus
Asynchronous programming in ASP.NET
Event Machine
Reactive programming with examples
Microservices with Spring Cloud
Queick: A Simple Job Queue System for Python
Reactive Streams: Handling Data-Flow the Reactive Way
Concurrency in ruby
Spring Boot to Quarkus: A real app migration experience | DevNation Tech Talk
Spring Cloud and Netflix OSS overview v1
Performance measurement methodology — Maksym Pugach | Elixir Evening Club 3
Understanding and Extending Prometheus AlertManager
Gabriele Provinciali/Gabriele Folchi/Luca Postacchini - Sviluppo con piattafo...
Asynchronous Python with Twisted
WTF is Twisted?
Microservices with Netflix OSS and Spring Cloud - Dev Day Orange
Reactive Card Magic: Understanding Spring WebFlux and Project Reactor
Reactive programming with RxJava
Building Scalable Stateless Applications with RxJava
CDK Meetup: Rule the World through IaC
Kubernetes and Prometheus
Ad

Viewers also liked (20)

PDF
Vert.X: Microservices Were Never So Easy (Clement Escoffier)
PPTX
Vert.x for Microservices Architecture
PPTX
Building microservices with vert.x 3.0
PPTX
autodiscoverable microservices with vertx3
PDF
An Introduction to Reactive Application, Reactive Streams, and options for JVM
PPTX
DDD-Enabling Architectures with EventStore
PDF
Building Evented Single Page Applications
PDF
Reactive programming
PPTX
Reactive web applications
PDF
Reactive Microservices with Vert.x
PDF
Case study - Nuskin: Statefull Applications in a Stateless World
PDF
Rxjava meetup presentation
PDF
Develop and Deploy Cloud-Native Apps as Resilient Microservice Architectures
PPTX
Patterns and practices for real-world event-driven microservices
PDF
Can Single Page Applications Deliver a World-Class Web UX?
PDF
RxJava 2.0 介紹
PDF
Securing Single-Page Applications with OAuth 2.0
PDF
Voxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVM
PPTX
Welcome to rx java2
PPTX
Rocks of Aia
Vert.X: Microservices Were Never So Easy (Clement Escoffier)
Vert.x for Microservices Architecture
Building microservices with vert.x 3.0
autodiscoverable microservices with vertx3
An Introduction to Reactive Application, Reactive Streams, and options for JVM
DDD-Enabling Architectures with EventStore
Building Evented Single Page Applications
Reactive programming
Reactive web applications
Reactive Microservices with Vert.x
Case study - Nuskin: Statefull Applications in a Stateless World
Rxjava meetup presentation
Develop and Deploy Cloud-Native Apps as Resilient Microservice Architectures
Patterns and practices for real-world event-driven microservices
Can Single Page Applications Deliver a World-Class Web UX?
RxJava 2.0 介紹
Securing Single-Page Applications with OAuth 2.0
Voxxed Days Vienna - The Why and How of Reactive Web-Applications on the JVM
Welcome to rx java2
Rocks of Aia
Ad

Similar to Modern app programming with RxJava and Eclipse Vert.x (20)

PDF
BASICS OF VERT.X - A toolkit for building asynchronous and reactive app
PDF
Vertx In Action Asynchronous And Reactive Java Julien Ponge
PPTX
Reactive for the Impatient - Mary Grygleski
PDF
An introduction to Reactive applications, Reactive Streams, and options for t...
PDF
Reactive Android: RxJava and beyond
PDF
Reactive Android: RxJava and beyond - Fabio Tiriticco - Codemotion Amsterdam ...
PPTX
Reactive programming - Dirk Janssen (presentation 13th SPIN Meetup)
PPT
Reactive java programming for the impatient
PPTX
The Reactive Landscape
PDF
Reactive microservices with eclipse vert.x
PPTX
Going Reactive with Java
PPTX
Reactive Programming on Android - RxAndroid - RxJava
PDF
TDC2017 | São Paulo - Trilha Java EE How we figured out we had a SRE team at ...
PDF
Building Reactive Microservices with Vert.x
PPT
Presentation - We live in a reactive world - TechForumIberia2016
PPTX
Reactive applications and microservices with Vert.x tool-kit
PDF
What is rxjava?
PPT
JUDCon Brazil 2013 - Vert.x an introduction
PDF
Mutiny + quarkus
PPTX
Vert.x devoxx london 2013
BASICS OF VERT.X - A toolkit for building asynchronous and reactive app
Vertx In Action Asynchronous And Reactive Java Julien Ponge
Reactive for the Impatient - Mary Grygleski
An introduction to Reactive applications, Reactive Streams, and options for t...
Reactive Android: RxJava and beyond
Reactive Android: RxJava and beyond - Fabio Tiriticco - Codemotion Amsterdam ...
Reactive programming - Dirk Janssen (presentation 13th SPIN Meetup)
Reactive java programming for the impatient
The Reactive Landscape
Reactive microservices with eclipse vert.x
Going Reactive with Java
Reactive Programming on Android - RxAndroid - RxJava
TDC2017 | São Paulo - Trilha Java EE How we figured out we had a SRE team at ...
Building Reactive Microservices with Vert.x
Presentation - We live in a reactive world - TechForumIberia2016
Reactive applications and microservices with Vert.x tool-kit
What is rxjava?
JUDCon Brazil 2013 - Vert.x an introduction
Mutiny + quarkus
Vert.x devoxx london 2013

Recently uploaded (20)

PDF
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
PPTX
ai tools demonstartion for schools and inter college
PDF
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
PPTX
ManageIQ - Sprint 268 Review - Slide Deck
PPTX
L1 - Introduction to python Backend.pptx
PDF
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
PDF
Internet Downloader Manager (IDM) Crack 6.42 Build 41
PDF
AI in Product Development-omnex systems
PPTX
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
PPTX
Transform Your Business with a Software ERP System
PDF
System and Network Administraation Chapter 3
PPTX
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
PPTX
history of c programming in notes for students .pptx
PDF
PTS Company Brochure 2025 (1).pdf.......
PDF
Nekopoi APK 2025 free lastest update
PDF
Which alternative to Crystal Reports is best for small or large businesses.pdf
PPTX
Online Work Permit System for Fast Permit Processing
PPT
Introduction Database Management System for Course Database
PDF
Odoo Companies in India – Driving Business Transformation.pdf
PPTX
Odoo POS Development Services by CandidRoot Solutions
T3DD25 TYPO3 Content Blocks - Deep Dive by André Kraus
ai tools demonstartion for schools and inter college
SAP S4 Hana Brochure 3 (PTS SYSTEMS AND SOLUTIONS)
ManageIQ - Sprint 268 Review - Slide Deck
L1 - Introduction to python Backend.pptx
Addressing The Cult of Project Management Tools-Why Disconnected Work is Hold...
Internet Downloader Manager (IDM) Crack 6.42 Build 41
AI in Product Development-omnex systems
Oracle E-Business Suite: A Comprehensive Guide for Modern Enterprises
Transform Your Business with a Software ERP System
System and Network Administraation Chapter 3
Agentic AI Use Case- Contract Lifecycle Management (CLM).pptx
history of c programming in notes for students .pptx
PTS Company Brochure 2025 (1).pdf.......
Nekopoi APK 2025 free lastest update
Which alternative to Crystal Reports is best for small or large businesses.pdf
Online Work Permit System for Fast Permit Processing
Introduction Database Management System for Course Database
Odoo Companies in India – Driving Business Transformation.pdf
Odoo POS Development Services by CandidRoot Solutions

Modern app programming with RxJava and Eclipse Vert.x