Upgrade to Pro — share decks privately, control downloads, hide ads and more …

Vert.x Montreal JUG 2018

Sponsored · SiteGround - Reliable hosting with speed, security, and support you can count on. →

Vert.x Montreal JUG 2018

Julien Ponge

October 25, 2018

Transcript

30 slides
  1. 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
  2. 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"); } }
  3. 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
  4. & ' & Http server verticle Database client verticle 

    Event Bus ) ' “Details for user 1234?” “{data}” 4 instances 1 instance
  5. 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”
  6. 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
  7. + , - . IceCast VLC * Chrome / DJ

    Booth app Clients / NuProcess MIDI Event Bus Event Bus
  8. 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);
  9. + , - . IceCast VLC Clients / OGG/Vorbis OGG/Vorbis

    MP3 MP3 HTTP 1.0 HTTP 1.1 HTTP Client Event bus → Chunked HTTP
  10. router.get("/audiostream").handler(context -> { HttpServerResponse response = context.response(); response.setStatusCode(200); response.setChunked(true); response.putHeader("Content-Type",

    "audio/mpeg"); MessageConsumer<Buffer> 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(); }); });
  11. 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)
  12. 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

More Decks by Julien Ponge

Other Decks in Programming