SlideShare a Scribd company logo
Building Reactive Microservices with Vert.x
Claudio Eduardo de Oliveira
About me
Claudio Eduardo de Oliveira
● Developer @ Daitan Group
● Bacharel em Ciência da Computação
● Cursando MBA em Arquitetura de Soluções em
Tecnologia (DeVry/Metrocamp)
● Entusiasta Docker / Spring / Vert.x
Contatos:
Email: claudioed.oliveira@gmail.com
Linkedin: https://br.linkedin.com/in/claudioedoliveira
Twitter: @claudioed
Agenda
● Microservices
○ Definition
○ Patterns
● Reactive Manifesto
○ Reactive Systems
○ Reactive Programming
● Vert.x
Definition
The term "Microservice Architecture" has sprung up over the last
few years to describe a particular way of designing software
applications as suites of independently deployable services.
While there is no precise definition of this architectural style, there
are certain common characteristics around organization around
business capability, automated deployment, intelligence in the
endpoints, and decentralized control of languages and data.
microservices
https://martinfowler.com/articles/microservices.html
Example microservices
https://cdn.wp.nginx.com/wp-content/uploads/2016/04/Richardson-microservices-part1-2_microservices-architecture.png
Microservices Patterns
● Circuit Breakers
● Service Discovery
microservices
Circuit Breaker microservices
“The basic idea behind the circuit breaker is very simple. You
wrap a protected function call in a circuit breaker object,
which monitors for failures”
https://martinfowler.com/bliki/CircuitBreaker.html
Service Discovery microservices
Service discovery is the automatic detection of devices and
services offered by these devices on a computer network
https://en.wikipedia.org/wiki/Service_discovery
reactiveReactive Manifesto
http://www.reactivemanifesto.org/
Reactive Systems
as defined by the Reactive Manifesto—is a set of
architectural design principles for building modern
systems that are well prepared to meet the
increasing demands that applications face today.
https://www.lightbend.com/reactive-programming-versus-reactive-systems
reactive
Reactive Programming
In computing, reactive programming is an
asynchronous programming paradigm
concerned with data streams and the
propagation of change
https://en.wikipedia.org/wiki/Reactive_programming
reactive
We will talk about Reactive Systems….
reactive
Some JVM players reactive
Building Reactive Microservices with Vert.x
Definition
Eclipse Vert.x is a toolkit for building
reactive applications on the JVM
vert.x
http://vertx.io/
Highlights
● Non-Blocking (vert.x core)
● Polyglot
● Event Bus
● General purpose
● Unopinionated
● Really fun to code
vert.x
Dependencies - Maven vert.x
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-dependencies</artifactId>
<version>${vertx.version}</version>
<type>pom</type>
<scope>import</scope>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-core</artifactId>
</dependency>
<dependency>
<groupId>io.vertx</groupId>
<artifactId>vertx-web</artifactId>
</dependency>
Core Concepts
Verticle
vert.x
Event Bus
Verticle vert.x
● Small Vert Unit
● Regular Verticle
● Worker Verticle
● Multi Threaded Worker
● Automatic node discovery
Reactor Pattern
The reactor pattern is one implementation technique of
event-driven architecture. In simple terms, it uses a single
threaded event loop blocking on resource-emitting events
and dispatches them to corresponding handlers and
callbacks
vert.x
https://dzone.com/articles/understanding-reactor-pattern-thread-based-and-eve
Regular Verticle - Event Loop vert.x
Regular Verticle
● Golden Rule - Don’t block me!
● Event Loop (more than one)
● Multi Reactor Pattern
● High throughput (i.e http)
vert.x
public class EventLoopVerticle extends AbstractVerticle {
public void start() {
final Router router = Router.router(vertx);
router.get("/test").handler(req -> {
req.response()
.putHeader("content-type","text/plain")
.end(NormalProcess.process());
});
vertx.createHttpServer().requestHandler(router::accept).listen(8080);
}
}
Regular Verticle - Example vert.x
Don't do this !!!! vert.x
public class EventLoopBlockerVerticle extends AbstractVerticle {
public void start() {
final Router router = Router.router(vertx);
router.get("/test").handler(req -> {
LongRunningProcess.longProcess();
final String date = LocalDateTime.now().toString();
req.response()
.putHeader("content-type","text/plain")
.end(String.format("TDC 2017 %s", date));
});
vertx.createHttpServer().requestHandler(router::accept).listen(8081);
}
}
Worker Verticle
● Vert.x worker thread pool
● Execute blocking code
● They are never executed by more than one thread
● Background tasks
vert.x
Worker Verticle vert.x
public class EventLoopBusVerticle extends AbstractVerticle {
public void start() {
this.vertx.deployVerticle(new BusVerticle(),
new DeploymentOptions().setWorker(true));
this.vertx.deployVerticle(new RequestResourceVerticle());
}
}
Multi Threaded Verticle
● Based on worker verticle
● Can be executed concurrently by different threads
● Hard to code because you need to maintain states
between verticles
● Specific needs
vert.x
Event Bus
● Nervous system of Vert.x
● Publish / Subscribe
● Point to Point
● Request Response
● Can be distributed
vert.x
Event Bus vert.x
public class RequestResourceVerticle extends AbstractVerticle {
private static final Logger LOGGER = LoggerFactory.getLogger(BusVerticle.class);
public void start() {
final EventBus eventBus = vertx.eventBus();
final Router router = Router.router(vertx);
router.get("/test").handler(req -> {
eventBus.send("data-stream", new JsonObject(), responseBus -> {
if (responseBus.succeeded()) {
req.response()
.putHeader("content-type", "text/plain")
.end(responseBus.result().body().toString());
}
});
});
vertx.createHttpServer().requestHandler(router::accept).listen(8082);
}
}
Service Discovery
This component provides an infrastructure to publish and
discover various resources, such as service proxies, HTTP
endpoints, data sources…​
vert.x
http://vertx.io/docs/vertx-service-discovery/java/
Service Discovery
Service provider
Publish / Unpublish service record
Update the status of a service
vert.x
http://vertx.io/docs/vertx-service-discovery/java/
Service Discovery
Service consumer
Lookup service
Bind to a selected service
Release the service
Listen for arrival and departure
vert.x
http://vertx.io/docs/vertx-service-discovery/java/
Service Discovery - Backend vert.x
final ServiceDiscoveryOptions serviceDiscoveryOptions = new
ServiceDiscoveryOptions()
.setBackendConfiguration(
new JsonObject()
.put("host", "127.0.0.1")
.put("port", "6379")
);
ServiceDiscovery sd = ServiceDiscovery.create(vertx,serviceDiscoveryOptions);
Service Discovery - Publish vert.x
vertx.createHttpServer().requestHandler(router::accept)
.rxListen(8083)
.flatMap(httpServer -> discovery
.rxPublish(HttpEndpoint.createRecord("product", "localhost", 8083, "/")))
.subscribe(rec -> LOGGER.info("Product Service is published"));
Service Discovery - Consumer vert.x
final ServiceDiscoveryOptions serviceDiscoveryOptions = new
ServiceDiscoveryOptions()
.setBackendConfiguration(
new JsonObject()
.put("host", "127.0.0.1")
.put("port", "6379")
);
ServiceDiscovery discovery = ServiceDiscovery.create(vertx,serviceDiscoveryOptions);
….
HttpEndpoint.rxGetWebClient(discovery, rec -> rec.getName().endsWith("product"))
.flatMap(client -> client.get("/product/" +
id).as(BodyCodec.string()).rxSend())
.subscribe(response -> req.response()
.putHeader("content-type", "application/json")
.end(response.body()));
});
Service Discovery
● Consul
● Kubernetes
● Redis
● Docker
vert.x
Circuit Breaker vert.x
https://www.oreilly.com/ideas/microservices-antipatterns-and-pitfalls
breaker.executeWithFallback(
future -> {
vertx.createHttpClient().getNow(8080, "localhost", "/", response -> {
if (response.statusCode() != 200) {
future.fail("HTTP error");
} else {
response
.exceptionHandler(future::fail)
.bodyHandler(buffer -> {
future.complete(buffer.toString());
});
}
});
}, v -> {
// Executed when the circuit is opened
return "Hello";
})
.setHandler(ar -> {
// Do something with the result
});
Circuit Breaker vert.x
vert.xDemo
Building Reactive Microservices with Vert.x
References
http://vertx.io/docs/guide-for-java-devs/
https://www.oreilly.com/ideas/reactive-programming-vs-reactive-systems
https://dzone.com/articles/understanding-reactor-pattern-thread-based-and-eve
https://developers.redhat.com/promotions/building-reactive-microservices-in-java/
https://github.com/claudioed/travel-helper

More Related Content

PPTX
Vert.x v3 - high performance polyglot application toolkit
PPTX
Vert.x for Microservices Architecture
PDF
Development with Vert.x: an event-driven application framework for the JVM
PPTX
Event driven microservices with vertx and kubernetes
PPTX
Vert.x vs akka
PDF
Spring Boot Revisited with KoFu and JaFu
PDF
Vert.x
PDF
YaJug - Cassandra for Java Developers
Vert.x v3 - high performance polyglot application toolkit
Vert.x for Microservices Architecture
Development with Vert.x: an event-driven application framework for the JVM
Event driven microservices with vertx and kubernetes
Vert.x vs akka
Spring Boot Revisited with KoFu and JaFu
Vert.x
YaJug - Cassandra for Java Developers

What's hot (20)

PDF
EclipseCon - Building an IDE for Apache Cassandra
PDF
Weaving Through the Mesh: Making Sense of Istio and Overlapping Technologies
PDF
Geneva JUG - Cassandra for Java Developers
PDF
vert.x 3.1 - be reactive on the JVM but not only in Java
PDF
JAX-RS 2.1 Reloaded @ Devoxx
PDF
Hands on: Hystrix
PDF
Meetup RomaJS - introduzione interattiva a Node.js - Luca Lanziani - Codemoti...
PPTX
Introduction to Node js
PPTX
Vert.x based microservices with vxms
PPTX
Building microservices with vert.x 3.0
PDF
Batch Applications for the Java Platform
PDF
Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...
KEY
Writing robust Node.js applications
PDF
Bulding a reactive game engine with Spring 5 & Couchbase
PDF
NodeJS: the good parts? A skeptic’s view (devnexus2014)
PDF
Swift Install Workshop - OpenStack Conference Spring 2012
PDF
Design Patterns para Microsserviços com MicroProfile
PDF
Adventures in Multithreaded Core Data
PDF
Cloud networking deep dive
KEY
OSCON 2011 - Node.js Tutorial
EclipseCon - Building an IDE for Apache Cassandra
Weaving Through the Mesh: Making Sense of Istio and Overlapping Technologies
Geneva JUG - Cassandra for Java Developers
vert.x 3.1 - be reactive on the JVM but not only in Java
JAX-RS 2.1 Reloaded @ Devoxx
Hands on: Hystrix
Meetup RomaJS - introduzione interattiva a Node.js - Luca Lanziani - Codemoti...
Introduction to Node js
Vert.x based microservices with vxms
Building microservices with vert.x 3.0
Batch Applications for the Java Platform
Universal JS Web Applications with React - Luciano Mammino - Codemotion Rome ...
Writing robust Node.js applications
Bulding a reactive game engine with Spring 5 & Couchbase
NodeJS: the good parts? A skeptic’s view (devnexus2014)
Swift Install Workshop - OpenStack Conference Spring 2012
Design Patterns para Microsserviços com MicroProfile
Adventures in Multithreaded Core Data
Cloud networking deep dive
OSCON 2011 - Node.js Tutorial
Ad

Similar to Building Reactive Microservices with Vert.x (20)

PPTX
PPTX
PDF
Reactive Polyglot Microservices with OpenShift and Vert.x
PDF
Reactive microservices with eclipse vert.x
PPTX
Reactive applications and microservices with Vert.x tool-kit
PDF
Utrecht JUG - Building microservices with Vert.x
PDF
Vertx In Action Asynchronous And Reactive Java Julien Ponge
PDF
Building microservices with Vert.X @ Fall 2016
PDF
Codemotion Amsterdam 2016 - Building microservices with Vert.x
PDF
Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterda...
PDF
Vert.X: Microservices Were Never So Easy (Clement Escoffier)
PDF
Building Reactive Microservices In Java 1st Edition Clement Escoffier
PDF
VJUG 24 - Building microservices with Vert.x
PPTX
Reactive Microservices with eclipse vert.x
PPTX
App Mod 04: Reactive microservices with eclipse vert.x
PDF
Building a High-Performance Reactive Microservices Architecture
PDF
JBCNConf 2017 - Building microservices with Vert.x
PDF
Malmberg meetup June 2018 - Building microservices with Vert.x
ODP
Build your reactive web application with Vert.x
PDF
Vert.x NL meetup October 2017 - Building microservices with Vert.x
Reactive Polyglot Microservices with OpenShift and Vert.x
Reactive microservices with eclipse vert.x
Reactive applications and microservices with Vert.x tool-kit
Utrecht JUG - Building microservices with Vert.x
Vertx In Action Asynchronous And Reactive Java Julien Ponge
Building microservices with Vert.X @ Fall 2016
Codemotion Amsterdam 2016 - Building microservices with Vert.x
Building microservices with Vert.x - Bert Jan Schrijver - Codemotion Amsterda...
Vert.X: Microservices Were Never So Easy (Clement Escoffier)
Building Reactive Microservices In Java 1st Edition Clement Escoffier
VJUG 24 - Building microservices with Vert.x
Reactive Microservices with eclipse vert.x
App Mod 04: Reactive microservices with eclipse vert.x
Building a High-Performance Reactive Microservices Architecture
JBCNConf 2017 - Building microservices with Vert.x
Malmberg meetup June 2018 - Building microservices with Vert.x
Build your reactive web application with Vert.x
Vert.x NL meetup October 2017 - Building microservices with Vert.x
Ad

Recently uploaded (20)

PDF
Network Security Unit 5.pdf for BCA BBA.
PPTX
Group 1 Presentation -Planning and Decision Making .pptx
PDF
Electronic commerce courselecture one. Pdf
PDF
Per capita expenditure prediction using model stacking based on satellite ima...
PDF
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
PPTX
SOPHOS-XG Firewall Administrator PPT.pptx
PDF
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
PDF
gpt5_lecture_notes_comprehensive_20250812015547.pdf
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PDF
Dropbox Q2 2025 Financial Results & Investor Presentation
PPTX
Tartificialntelligence_presentation.pptx
PDF
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
PPTX
1. Introduction to Computer Programming.pptx
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
NewMind AI Weekly Chronicles - August'25-Week II
PPT
Teaching material agriculture food technology
PPTX
Digital-Transformation-Roadmap-for-Companies.pptx
PDF
Machine learning based COVID-19 study performance prediction
PDF
Approach and Philosophy of On baking technology
PDF
Assigned Numbers - 2025 - Bluetooth® Document
Network Security Unit 5.pdf for BCA BBA.
Group 1 Presentation -Planning and Decision Making .pptx
Electronic commerce courselecture one. Pdf
Per capita expenditure prediction using model stacking based on satellite ima...
7 ChatGPT Prompts to Help You Define Your Ideal Customer Profile.pdf
SOPHOS-XG Firewall Administrator PPT.pptx
Profit Center Accounting in SAP S/4HANA, S4F28 Col11
gpt5_lecture_notes_comprehensive_20250812015547.pdf
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Dropbox Q2 2025 Financial Results & Investor Presentation
Tartificialntelligence_presentation.pptx
Optimiser vos workloads AI/ML sur Amazon EC2 et AWS Graviton
1. Introduction to Computer Programming.pptx
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
NewMind AI Weekly Chronicles - August'25-Week II
Teaching material agriculture food technology
Digital-Transformation-Roadmap-for-Companies.pptx
Machine learning based COVID-19 study performance prediction
Approach and Philosophy of On baking technology
Assigned Numbers - 2025 - Bluetooth® Document

Building Reactive Microservices with Vert.x