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
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
プロダクトオーナーから見たSOC2 _SOC2ゆるミートアップ#2
kekekenta
0
220
コントリビューターによるDenoのすゝめ / Deno Recommendations by a Contributor
petamoriken
0
200
AWS re:Invent 2025参加 直前 Seattle-Tacoma Airport(SEA)におけるハードウェア紛失インシデントLT
tetutetu214
2
110
そのAIレビュー、レビューしてますか? / Are you reviewing those AI reviews?
rkaga
6
4.6k
izumin5210のプロポーザルのネタ探し #tskaigi_msup
izumin5210
1
130
CSC307 Lecture 01
javiergs
PRO
0
690
フロントエンド開発の勘所 -複数事業を経験して見えた判断軸の違い-
heimusu
7
2.8k
並行開発のためのコードレビュー
miyukiw
0
180
Best-Practices-for-Cortex-Analyst-and-AI-Agent
ryotaroikeda
1
110
HTTPプロトコル正しく理解していますか? 〜かわいい猫と共に学ぼう。ฅ^•ω•^ฅ ニャ〜
hekuchan
2
690
Vibe Coding - AI 驅動的軟體開發
mickyp100
0
180
余白を設計しフロントエンド開発を 加速させる
tsukuha
7
2.1k
Featured
See All Featured
XXLCSS - How to scale CSS and keep your sanity
sugarenia
249
1.3M
Have SEOs Ruined the Internet? - User Awareness of SEO in 2025
akashhashmi
0
270
Fashionably flexible responsive web design (full day workshop)
malarkey
408
66k
Heart Work Chapter 1 - Part 1
lfama
PRO
5
35k
ReactJS: Keep Simple. Everything can be a component!
pedronauck
666
130k
ピンチをチャンスに:未来をつくるプロダクトロードマップ #pmconf2020
aki_iinuma
128
55k
The Psychology of Web Performance [Beyond Tellerrand 2023]
tammyeverts
49
3.3k
Intergalactic Javascript Robots from Outer Space
tanoku
273
27k
SERP Conf. Vienna - Web Accessibility: Optimizing for Inclusivity and SEO
sarafernandez
1
1.3k
How To Speak Unicorn (iThemes Webinar)
marktimemedia
1
380
Paper Plane (Part 1)
katiecoart
PRO
0
4.2k
Fight the Zombie Pattern Library - RWD Summit 2016
marcelosomers
234
17k
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