vert.x

Effortless asynchronous application development for the modern web and enterprise

Polyglot


Write your application components in JavaScript, Ruby, Groovy or Java. Or mix and match several programming languages in a single application.

Simplicity


...without being simplistic. Create real, scalable applications in just a few lines of code. No sprawling xml config.


Scalability


Scale using messaging passing and immutable shared data to efficiently utilise your server cores.



Concurrency


Super-simple concurrency model frees you from the hassles of traditional multi-threaded programming.



Features


  • Distributed Event Bus which spans the server and even penetrates into client side JavaScript for effortless 'real-time' web applications.

  • Out of the box event bus modules including a web-server, persistor, mailer and work queues.

  • TCP/SSL servers and clients

  • HTTP/HTTPS servers and clients

  • WebSockets support

  • SockJS support

  • Extensive documentation

  • Open Source. Licenced under the ASL 2.0

  • Embeddable. If you don't want to run the whole vert.x platform, you can use vert.x embedded as a library in your own Java or Groovy application.

  • Many other features. See the documentation for full details.

Show me the code


Here's a highly scalable web server. It serves files from the webroot directory.

(Click on the tab below for your preferred language)

Save the following in server.js

load('vertx.js')

vertx.createHttpServer().requestHandler(function(req) {
    var file = req.path === '/' ? 'index.html' : req.path;
    req.response.sendFile('webroot/' + file);
}).listen(8080)
                

Run it with:

vertx run server.js

Have lots of cores on your server and want to use them all?

Just spin up more instances:

vertx run server.js -instances 32

Vert.x will do the magic to ensure the requests are distributed amongst the instances:

Save the following in server.rb

require "vertx"

Vertx::HttpServer.new.request_handler do |req|
    file = req.uri == "/" ? "index.html" : req.uri
    req.response.send_file "webroot/#{file}"
end.listen(8080)
                

Run it with:

vertx run server.rb

Have lots of cores on your server and want to use them all?

Just spin up more instances:

vertx run server.rb -instances 32

Vert.x will do the magic to ensure the requests are distributed amongst the instances:

Save the following in Server.groovy

vertx.createHttpServer().requestHandler { req ->
    def file = req.uri == "/" ? "index.html" : req.uri
    req.response.sendFile "webroot/$file"
}.listen(8080)
                

Run it with:

vertx run Server.groovy

Have lots of cores on your server and want to use them all?

Just spin up more instances:

vertx run Server.groovy -instances 32

Vert.x will do the magic to ensure the requests are distributed amongst the instances:

Save the following in Server.java

import org.vertx.java.core.Handler;
import org.vertx.java.core.http.HttpServerRequest;
import org.vertx.java.deploy.Verticle;

public class Server extends Verticle {
    public void start() {
        vertx.createHttpServer().requestHandler(new Handler<HttpServerRequest>() {
            public void handle(HttpServerRequest req) {
                String file = req.path.equals("/") ? "index.html" : req.path;
                req.response.sendFile("webroot/" + file);
            }
        }).listen(8080);
    }
}
                

Compile it:

javac Server.java -cp $VERTX_HOME/lib/jars/vert.x-core.jar:$VERTX_HOME/lib/jars/vert.x-platform.jar

Run it with:

vertx run Server

Have lots of cores on your server and want to use them all?

Just spin up more instances:

vertx run Server -instances 32

Vert.x will do the magic to ensure the requests are distributed amongst the instances:

OK, that's pretty cool, but it's just a Hello World.

For something more substantial take a look at the tutorials

.