Slide 1

Slide 1 text

Julien Ponge Thomas Segismont @jponge @tsegismont

Slide 2

Slide 2 text

Shameless plug

Slide 3

Slide 3 text

Reactive? (because resources are scarce)

Slide 4

Slide 4 text

No content

Slide 5

Slide 5 text

Application

Slide 6

Slide 6 text

Reactive systems Reactive streams Reactive programming Reactive “Responding to stimuli” Manifesto, Actor, Messages Resilience, Elasticity, Scalability, Asynchronous, non-blocking Data flow Back-pressure Non-blocking Data flow Events, Observable Spreadsheets Akka, Vert.x Akka Streams, RxJava, Reactor, Vert.x Reactor, Reactive Spring, RxJava, Vert.x

Slide 7

Slide 7 text

while (isRunning) { String line = bufferedReader.readLine(); switch (line.substring(0, 4)) { case "ECHO": bufferedWriter.write(line); break // ... // other cases ( ...) // ... default: bufferedWriter.write("UNKW Unknown command"); } }

Slide 8

Slide 8 text

x 1000 = !

Slide 9

Slide 9 text

Virtual machines, Containers, etc

Slide 10

Slide 10 text

No content

Slide 11

Slide 11 text

Vert.x? (async all the things!)

Slide 12

Slide 12 text

Eclipse Vert.x Open source project started in 2012 Eclipse / Apache licensing A toolkit for building reactive applications for the JVM 7K ⋆ on # Built on top of $ https://vertx.io % @vertx_project

Slide 13

Slide 13 text

& ' & Http server verticle Database client verticle  Event Bus ) ' “Details for user 1234?” “{data}” 4 instances 1 instance

Slide 14

Slide 14 text

Events Thread Event Loop & & & & &

Slide 15

Slide 15 text

(demo) Hello Vert.x

Slide 16

Slide 16 text

No content

Slide 17

Slide 17 text

foo.a(1, res1 -> { if (res1.succeeded()) { bar.b("abc", 1, res2 -> { if (res.succeeded()) { baz.c(res3 -> { dosomething(res1, res2, res3, res4 -> { // (...) }); }); } }); } }); “Callback hell”

Slide 18

Slide 18 text

Callbacks RxJava 1 + 2 Quasar (vertx-sync) Kotlin coroutines (core) (codegen)

Slide 19

Slide 19 text

Boiler Vroom (in the mix)

Slide 20

Slide 20 text

(demo)

Slide 21

Slide 21 text

* ) WebMidi JSON / Event Bus

Slide 22

Slide 22 text

const eventBus = new EventBus("/eventbus") traktorIn.addListener("controlchange", 5, (event) => { eventBus.publish("boilervroom.vu-meter", { type: "volume-level", value: event.value }) }) eventBus.publish("boilervroom.fromtraktor", { type: "filter", number: 1, value: (event.value !== 0) }) Event Bus

Slide 23

Slide 23 text

+ , - . IceCast VLC * Chrome / DJ Booth app Clients / NuProcess MIDI Event Bus Event Bus

Slide 24

Slide 24 text

SockJSHandler sockJSHandler = SockJSHandler.create(vertx); PermittedOptions permittedOptions = new PermittedOptions() .setAddressRegex(“boilervroom\\ ..+”); BridgeOptions bridgeOptions = new BridgeOptions() .addInboundPermitted(permittedOptions) .addOutboundPermitted(permittedOptions); sockJSHandler.bridge(bridgeOptions); router.route("/eventbus /*").handler(sockJSHandler);

Slide 25

Slide 25 text

+ , - . IceCast VLC Clients / OGG/Vorbis OGG/Vorbis MP3 MP3 HTTP 1.0 HTTP 1.1 HTTP Client Event bus → Chunked HTTP

Slide 26

Slide 26 text

router.get("/audiostream").handler(context -> { HttpServerResponse response = context.response(); response.setStatusCode(200); response.setChunked(true); response.putHeader("Content-Type", "audio/mpeg"); MessageConsumer consumer = eventBus.consumer("boilervroom.audiostream"); consumer.bodyStream().handler(buffer -> { if (!response.writeQueueFull()) { response.write(buffer); } }); response.endHandler(v -> { consumer.unregister(); }); response.exceptionHandler(t -> { consumer.unregister(); }); });

Slide 27

Slide 27 text

Outro

Slide 28

Slide 28 text

Unified end-to-end reactive model + ecosystem (not just APIs…) For all kinds of distributed applications (even the small-scale ones) Flexible toolkit, not a framework (your needs, your call)

Slide 29

Slide 29 text

https: //youtu.be/ZkWsilpiSqw 0 Applications réactives avec Eclipse Vert.x 1 Building Reactive Microservices in Java https: //goo.gl/ep6yB9 1 Guide to async programming with Vert.x for Java developers https: //goo.gl/AcWW3A

Slide 30

Slide 30 text

Q&A Use mlponge to get 50% off