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
·
Your Podcast. Everywhere. Effortlessly.
Share. Educate. Inspire. Entertain. You do you. We'll handle the rest.
→
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
humanlayerのブログから学ぶ、良いCLAUDE.mdの書き方
tsukamoto1783
0
200
2026年 エンジニアリング自己学習法
yumechi
0
140
Best-Practices-for-Cortex-Analyst-and-AI-Agent
ryotaroikeda
1
110
LLM Observabilityによる 対話型音声AIアプリケーションの安定運用
gekko0114
2
430
The Past, Present, and Future of Enterprise Java
ivargrimstad
0
580
Rust 製のコードエディタ “Zed” を使ってみた
nearme_tech
PRO
0
180
Unicodeどうしてる? PHPから見たUnicode対応と他言語での対応についてのお伺い
youkidearitai
PRO
1
2.6k
Apache Iceberg V3 and migration to V3
tomtanaka
0
160
コントリビューターによるDenoのすゝめ / Deno Recommendations by a Contributor
petamoriken
0
200
16年目のピクシブ百科事典を支える最新の技術基盤 / The Modern Tech Stack Powering Pixiv Encyclopedia in its 16th Year
ahuglajbclajep
5
1k
そのAIレビュー、レビューしてますか? / Are you reviewing those AI reviews?
rkaga
6
4.6k
AI時代の認知負荷との向き合い方
optfit
0
160
Featured
See All Featured
New Earth Scene 8
popppiees
1
1.5k
Put a Button on it: Removing Barriers to Going Fast.
kastner
60
4.2k
Reflections from 52 weeks, 52 projects
jeffersonlam
356
21k
Principles of Awesome APIs and How to Build Them.
keavy
128
17k
Navigating Team Friction
lara
192
16k
Odyssey Design
rkendrick25
PRO
1
500
Ecommerce SEO: The Keys for Success Now & Beyond - #SERPConf2024
aleyda
1
1.8k
Navigating the moral maze — ethical principles for Al-driven product design
skipperchong
2
250
Raft: Consensus for Rubyists
vanstee
141
7.3k
Leveraging Curiosity to Care for An Aging Population
cassininazir
1
160
Darren the Foodie - Storyboard
khoart
PRO
2
2.4k
Build The Right Thing And Hit Your Dates
maggiecrowley
38
3k
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