Upgrade to Pro
— share decks privately, control downloads, hide ads and more …
Speaker Deck
Features
Speaker Deck
PRO
Sign in
Sign up for free
Search
Search
Reactive Microservices based on Vert.x
Search
Sponsored
·
SiteGround - Reliable hosting with speed, security, and support you can count on.
→
Kristian Kottke
March 19, 2019
Programming
0
220
Reactive Microservices based on Vert.x
Kristian Kottke
March 19, 2019
Tweet
Share
More Decks by Kristian Kottke
See All by Kristian Kottke
Jeder wie er will, aber so nicht
kkottke
0
37
Turmbau_zu_Babel.pdf
kkottke
0
110
Stream Processing with Apache Flink
kkottke
0
170
Graph Processing using Apache Flink
kkottke
0
110
Other Decks in Programming
See All in Programming
Patterns of Patterns
denyspoltorak
0
1.4k
AIエージェントのキホンから学ぶ「エージェンティックコーディング」実践入門
masahiro_nishimi
5
470
Oxlint JS plugins
kazupon
1
960
QAフローを最適化し、品質水準を満たしながらリリースまでの期間を最短化する #RSGT2026
shibayu36
2
4.4k
Automatic Grammar Agreementと Markdown Extended Attributes について
kishikawakatsumi
0
190
CSC307 Lecture 08
javiergs
PRO
0
670
AI によるインシデント初動調査の自動化を行う AI インシデントコマンダーを作った話
azukiazusa1
1
740
そのAIレビュー、レビューしてますか? / Are you reviewing those AI reviews?
rkaga
6
4.6k
コントリビューターによるDenoのすゝめ / Deno Recommendations by a Contributor
petamoriken
0
200
Vibe Coding - AI 驅動的軟體開發
mickyp100
0
180
Architectural Extensions
denyspoltorak
0
290
プロダクトオーナーから見たSOC2 _SOC2ゆるミートアップ#2
kekekenta
0
220
Featured
See All Featured
Writing Fast Ruby
sferik
630
62k
Why You Should Never Use an ORM
jnunemaker
PRO
61
9.7k
Six Lessons from altMBA
skipperchong
29
4.1k
Let's Do A Bunch of Simple Stuff to Make Websites Faster
chriscoyier
508
140k
How Fast Is Fast Enough? [PerfNow 2025]
tammyeverts
3
450
Docker and Python
trallard
47
3.7k
Primal Persuasion: How to Engage the Brain for Learning That Lasts
tmiket
0
250
[SF Ruby Conf 2025] Rails X
palkan
1
750
Building AI with AI
inesmontani
PRO
1
700
Lightning talk: Run Django tests with GitHub Actions
sabderemane
0
120
We Analyzed 250 Million AI Search Results: Here's What I Found
joshbly
1
720
個人開発の失敗を避けるイケてる考え方 / tips for indie hackers
panda_program
122
21k
Transcript
JavaLand Kristian Kottke Going Reactive Reactive Microservices based on Vert.x
©iteratec Whoami Kristian Kottke › Lead Software Engineer -> iteratec
Interests › Software Architecture › Big Data Technologies
[email protected]
@_kkottke github.com/kkottke xing.to/kkottke speakerdeck.com/kkottke
©iteratec
©iteratec Photo by Markus Spiske on Unsplash
©iteratec Microservice cloud native fault tolerance highly responsive scalable resilient
high availability multi core asynchronous flexible loosely coupled elastic Reactive System
©iteratec Reactive Systems
©iteratec Reactive Manifesto Responsive Resilient Elastic Message Driven
©iteratec Reactive Programming != Reactive Systems
©iteratec
©iteratec ...a toolkit for building reactive, non-blocking, asynchronous applications on
the JVM (based on netty with additional modules)
©iteratec !=
©iteratec ==
©iteratec !=
©iteratec
©iteratec Event Bus Host JVM Vert.x Instance Verticle (Java) Verticle
(Java) Verticle (JS) Verticle (Kotlin) JVM Vert.x Instance Verticle (Java) Verticle (Java) Verticle (JS) Verticle (Kotlin)
©iteratec Event Bus Host JVM Vert.x Instance Verticle (Java) Verticle
(Java) Verticle (JS) Verticle (Kotlin) Host JVM Vert.x Instance Verticle (Java) Verticle (Java) Verticle (JS) Verticle (Kotlin)
©iteratec Event Bus Host JVM Vert.x Instance Verticle (Java) Verticle
(Java) Verticle (JS) Verticle (Kotlin) Event Bus Bridge
©iteratec Reactor Pattern Event Queue Event Loop Handler Handler Handler
©iteratec Multi-Reactor Pattern ...
©iteratec Code
©iteratec Message Traders Generator Service Portfolio Message Audit ElasticSearch Kibana
Message REST
©iteratec public static void main(String[] args) { Vertx vertx =
new Vertx(); vertx.deployVerticle(new RestApiVerticle()); } Verticle
©iteratec public void start(Future<Void> future) { HttpServer server = vertx.createHttpServer()
.requestHandler(req -> req.response().end(„hello“)); server.listen(8080, res -> { if (res.succeeded()) { future.complete(); } else { future.fail(res.cause()); }}); } RestApiVerticle
©iteratec Don’t call us, we’ll call you! ›Synchronous (blocking) compute(1,
2); ›Asynchronous (non-blocking) compute(1, 2, res -> {…}); ›Everything is an event → Handler → Callback Hell → RX
©iteratec Digression: ReactiveX ›API for async programming with observable streams
›Observable › Evolution of Callback, Promise, Future › Subscribe: next, error, complete › Completable, Single, Maybe, Flowable ›Reactive Operators Observable Observable Subcriber onNext Produce
©iteratec public Completable rxStart() { return vertx.createHttpServer() .requestHandler(req -> req.response().end(„hello“))
.rxListen(8080) .ignoreElement(); } RestApiVerticle (rxified)
©iteratec public Completable rxStart() { return OpenAPI3RouterFactory.rxCreate(vertx, „api.yml“) .map(factory ->
{ factory.addHandlerByOperationId(„op“, this:op); return factory.getRouter(); }) .flatMap(router -> vertx.createHttpServer() .requestHandler(router) .rxListen(8080)) .ignoreElement(); } Web API Contract
©iteratec public void publish(Message mes) { vertx.eventBus().publish(„addr“, Json.encode(mes)); vertx.eventBus().rxSend(„addr“, Json.encode(mes));
} public void handle() { vertx.eventBus().<String>consumer(„addr“, m -> { Message mes = Json.decodeValue(m.body(), Message.class); .... } } Event Bus
©iteratec Message Traders Generator Service Portfolio Message Audit ElasticSearch Kibana
Message REST
©iteratec @ProxyGen @VertxGen public interface TradingService { @Fluent TradingService buy(int
amount, JsonObject json, Handler<AsyncResult<Portfolio>> handler); } Service Proxy (RPC)
©iteratec public void publish() { ServiceDiscovery sd = ServiceDiscovery.create(vertx); Record
http = HttpEndpoint.createRecord(...); Record message = MessageSource.createRecord(...); Record service = EventBusService.createRecord(...); sd.rxPublish(http); } Service Discovery
©iteratec public void consume() { ServiceDiscovery sd = ServiceDiscovery.create(vertx); client
= HttpEndpoint.rxGetWebClient(sd, json); consumer = MessageSource.rxGetConsumer(sd, json); proxy = EventBusService.getServiceProxy(sd, ...); } Service Discovery
©iteratec Failure Handling ›Error Handler › subscribe(success, error) ›Error Operator
› doOnError, onErrorReturn, ... ›Timeout Operator › timeout ›Retry Operator › retry, retryWhen ›Circuit Breaker › breaker.execute(...)
©iteratec Are we reactive now? ›Reactive Programming › Asynchronous, non-blocking
› Event-Driven ›Reactive System › Responsive › Resilient › Elastic › Message-Driven
©iteratec
©iteratec Modules ›Config ›Health Check ›Web (SockJS) ›Unit / Junit
5 ›Web API Service ›gRPC ›Sync
©iteratec When/Why Vert.x? ›Small Services ›Reactive Application ›Scalability ›Cloud Environment
›Polyglot
©iteratec Demo
©iteratec Wrap Up ›Toolkit for building reactive, non-blocking applications ›Multi-Reactor
Pattern & Event Bus › Asynchronous › Event-Driven › Performance & Scalability
©iteratec
[email protected]
@_kkottke github.com/kkottke xing.to/kkottke speakerdeck.com/kkottke https://github.com/kkottke/stock-trading.git
www.iteratec.de Contact Kristian Kottke
[email protected]
@_kkottke github.com/kkottke xing.to/kkottke speakerdeck.com/kkottke