Vert.x Montreal JUG 2018

Vert.x Montreal JUG 2018

50a17cd98aab2cc4d8e144741e11b1b7?s=128

Julien Ponge

October 25, 2018
Tweet

Transcript

  1. Julien Ponge Thomas Segismont @jponge @tsegismont

  2. Shameless plug

  3. Reactive? (because resources are scarce)

  4. None
  5. Application

  6. 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
  7. 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"); } }
  8. x 1000 = !

  9. Virtual machines, Containers, etc

  10. None
  11. Vert.x? (async all the things!)

  12. 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
  13. & ' & Http server verticle Database client verticle 

    Event Bus ) ' “Details for user 1234?” “{data}” 4 instances 1 instance
  14. Events Thread Event Loop & & & & &

  15. (demo) Hello Vert.x

  16. None
  17. 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”
  18. Callbacks RxJava 1 + 2 Quasar (vertx-sync) Kotlin coroutines (core)

    (codegen)
  19. Boiler Vroom (in the mix)

  20. (demo)

  21. * ) WebMidi JSON / Event Bus

  22. 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
  23. + , - . IceCast VLC * Chrome / DJ

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

    MP3 MP3 HTTP 1.0 HTTP 1.1 HTTP Client Event bus → Chunked HTTP
  26. 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(); }); });
  27. Outro

  28. 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)
  29. 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
  30. Q&A Use mlponge to get 50% off