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

QConSP 2018: Modern app programming with Eclips...

QConSP 2018: Modern app programming with Eclipse Vert.x and RxJava

With the advent of mobile web and IoT (Internet of Things), today's applications need to handle a lot of concurrent requests while staying responsive and easy to scale. But on the performance side, the party is over: the exponential increase promised by the Moore's law reached its limits. From now on, we need a programming paradigm switch to make the most of multicore architecture innovations.

In this presentation, we will make the case for reactive programming. Then we will guide you through the process of building a real-life web application, based on Vert.x 3 and RxJava2, communicating with databases, external services and modern datastores. You will learn how Vert.x integrates with RxJava, and why its simplicity makes it a perfect runtime for reactive applications.

Thomas Segismont

May 10, 2018
Tweet

More Decks by Thomas Segismont

Other Decks in Programming

Transcript

  1. #QConSP @vertx_project Who am I? Vert.x core team member since

    2016 Working at since 2012 Contributing specifically to monitoring and clustering @tsegismont
  2. Eclipse Vert.x A toolkit to build reactive applications on the

    JVM Started in 2O12 Eclipse / Apache licensing 7K on Built on top of Netty @vertx_project https://vertx.io
  3. #QConSP @vertx_project Pay the right price • Tiny footprint •

    Do one thing and do it well • Modular set of extensions
  4. while (isRunning) { String line = bufferedReader.readLine(); switch (line.substring(0, 4))

    { case "ECHO": bufferedWriter.write(line); break; // ... // other cases (...) // ... } }
  5. class HttpServerVerticle extends AbstractVerticle { public static void main(String[] args)

    { Vertx vertx = Vertx.vertx(); vertx.deployVerticle(HttpServerVerticle.class.getName()); } @Override public void start() throws Exception { vertx.createHttpServer() .requestHandler(req -> { req.response().end("Hello world!"); }).listen(8080); } } Verticles
  6. EventBus eventBus = vertx.eventBus(); eventBus.<String>consumer("greeting").handler(msg -> { String name =

    msg.body(); msg.reply(String.format("Hello %s!", name)); }); EventBus eventBus = vertx.eventBus(); eventBus.<String>send("greeting", "QConSP", ar -> { if (ar.succeeded()) { System.out.println(ar.result().body()); } else { ar.cause().printStackTrace(); } }); 1 2
  7. #QConSP @vertx_project Rxified ReadStream<T> class AsyncFile implements ReadStream<Buffer> { //

    ... // RxJava1 Observable<Buffer> toObservable(); // RxJava2 Flowable<Buffer> toFlowable(); // ... }