The next-gen polyglot asynchronous platform

Norman Maurer

  • Red Hat (JBoss) - EAP Core Team
  • Former contractor for Apple Inc
  • Author - Netty in Action
  • Apache Software Foundation Member
  • Netty  / Vert.x Core-Developer and all things NIO
  • Java and Scala
  • Twitter: @normanmaurer
  • Github: https://github.com/normanmaurer
  • Blog: http://normanmaurer.me
  • What is Vert.x ?

    Vert.x is a lightweight, high performance application platform for the JVM that's designed for modern mobile, web, and enterprise applications...

    General

    • Asynchronous by nature
    • General purpose
    • High-Performing
    • Polyglot
    • Flexible

    ... and many more

    Philosophy

    • Slim and leightweight core
    • Everything else as module
    • Reusable modules

    Supported Core Protocols

    • TCP / UDP
    • HTTP(s) and compression*
    • WebSockets / Secure-WebSockets
    • SockJS
    • DNS Client*

    * Will be avaible in 2.1.0

    Other Core Features

    • FileSystem API
    • EventBus
    • Timer (Periodic, one-shot)
    • Scaling
    • Run compiled and source files
    • Shared-data
    • Standalone (container like) and Embedded mode
    • Auto-redeploy of Modules
    • Pumps

    Supported languages

    • Java
    • JavaScript
    • Groovy
    • Ruby
    • Python
    • Scala*
    • Clojure*
    • PHP*
    * Still in heavy development

    Thread-Model

    • Powered by n EventLoops (Usually one per Core)
    • Each Verticle bound to one EventLoop and so single-Threaded
    • No concurrency issues , YAY
    • WorkerVerticle can be bound to an non EventLoop Thread
    • WorkerVerticles are useful for blocking calls (like legancy frameworks)
    • Run tasks on the EventLoop of the Verticle
    Never block the EventLoop!

    Internals

    • Build on top of Netty 4
    • Uses Hazelcast for node discovery
    • Jackson for JSON
    • Java7+

    Build-tool agnostic / IDE support

    • Gradle template
    • Maven archtype
    • Works in any IDE without special configuration

    Modules

    © http://www.flickr.com/photos/27620885@N02/2602771507/ by Rovert Ferrell D

    Bundle up your stuff!

    Modules - all over the place

    • New non-core features done as modules
    • => No changes to core needed
    • Get involved more easily
    • Runnable modules vs. includable modules
    • Even new language support is done via modules!
    • Modules are more less just a zip file (with meta-data)
    • Modules can include / depend on other modules
    • Applications are often bundled in modules

    Modules - Where to put them

    • Upload your modules to maven repository or bintray
    • Register the modules to the Module Registry
    • No license restriction but ASL2 / BSD / MIT is welcome ;)

    Modules - Ready to use

    • JDBC
    • MongoDB
    • Redis
    • Mailer
    • Yoke
    • async-postgres / mysql*

    ... and many more

    Testing

    • Testing Framework provided
    • Intergration-Testing
    • Unit Testing

    EventBus

    • Pass messages around, prefered JSON
    • Interact with other modules
    • Pub-Sub, Request/Response
    • May be distributed
    • Can even be used on the Browser vi JavaScript

    EventBus in action - Receive messages

    public class Receiver extends Verticle {
        @Override
        public void start() {
            vertx.eventBus().registerHandler("news-feed", new Handler>() {
                @Override
                public void handle(Message message) {
                    System.out.println("Received news: " + message.body());
                }
            });
        }
    }

    EventBus in action - Send messages

    public class Sender extends Verticle {
        @Override
        public void start() {
            // Publish some news on the feed every second
            vertx.setPeriodic(1000, new Handler() {
                @Override
                public void handle(Long timerID) {
                    vertx.eventBus().publish("news-feed", "more news!");
                }
            });
        }
    }
    Hmmm... so polyglot? Time to see it in action

    in Java ...

    public class ServerExample extends Verticle {
        @Override
        public void start() {
        	vertx.createHttpServer().requestHandler(new Handler() {
                public void handle(HttpServerRequest req) {
                    req.response().headers().set(
                         "Content-Type", "text/html; charset=UTF-8");
                    req.response().end(
                         "<html><body><h1>Hello from Vert.x!</h1></body></html>");
                }
            }).listen(8080);
        }
    }

    in JavaScript ...

    var vertx = require('vertx')
    vertx.createHttpServer().requestHandler(function(req) {
        req.response.end(
    		"<html><body><h1>Hello from Vert.x!</h1></body></html>");
    }).listen(8080);

    In Groovy ...

    vertx.createHttpServer().requestHandler { req ->
        req.response.end 
            "<html><body><h1>Hello from Vert.x!</h1></body></html>"
    }.listen(8080, "localhost")

    Project info

    • Eclipse Foundation
    • ASL2 License
    • Community Driven
    • Small Team but growing
    • Current stable version 2.0.2.Final

    Things to come...

    • HA/Clustering*
    • Fat-Jars*
    • StartTLS support
    • More Performance tuning ;)
    • Metrics ?
    • Cluster-wide Shared-Data

    ... and many more

    Join Us...

    It's opensource for a good reason
    • Github: https://github.com/eclipse/vert.x
    • IRC: irc.freenode.net #vertx
    • Google group: vertx
    • Twitter: @vertx_project

    Questions?

    Thanks