Tech and Media Labs
This site uses cookies to improve the user experience.

Vert.x Tutorial

Jakob Jenkov
Last update: 2015-04-20

Vert.x is an open source, reactive, polyglot toolkit or platform running on the Java Virtual Machine. You can think of Vert.x as an alternative to the Java Enterprise Edition but with a different approach to solving the same problem - developing networked, highly concurrent applications. You will see how in the following sections.

You can find Vert.x here:

Vert.x as a Toolkit or Platform

Vert.x can be used like toolkit. You can embed Vert.x in your standalone Java application, instantiate a Vertx object and call methods on it to get Vert.x to do what you need it to. In toolkit mode your code controls Vert.x.

Vert.x can also function like a platform. You can startup Vert.x from the command line and tell it what components of yours to run. This is similar to how you normally start up a Java EE application server.

Vert.x is Reactive

Vert.x calls itself a reactive toolkit. Reactive applications consists of components that send messages or events to each other. This is quite a different internal design than Java EE. This internal design makes Vert.x suitable for different types of applications than Java EE (for instance chat and game servers). In fact, I would risk the bold claim that Vert.x is suitable for more types of applications than Java EE.

In my tutorial about concurrency models I explain the different concurrency models that Java EE and Vert.x use. Java EE uses the parallel worker model. Vert.x on the other hand, uses the assembly line model with channels.

Vert.x is Polyglot

Vert.x is polyglot meaning you can implement the components you want Vert.x to execute (called "Verticles") in many different languages. Vertx. can execute Java, JavaScript, Ruby, Python and Groovy. Support for Scala and Clojure should be arriving soon (it was originally planned for v. 3.0 but I am not sure if they got it in). I have also seen rumors about support for PHP and Ceylon.

Vert.x can even deploy verticles written in different languages into the same application. This gives you the freedom to choose the most suitable language for each job. Some tasks might be easier to implement using a functional language like Scala. Others easier in a more traditionally imperative language like Java.

The polyglot nature of Vert.x also gives you the freedom to experiment with new languages to see if they suit your type of applications better. You can write the same tasks in different languages and compare.

If you are new to Vert.x but know one of the programming languages Vert.x can execute, you just have to focus on learning Vert.x and not a new programming language too. This makes Vert.x easier to learn regardless of what programming language you already know (as long as it is a language that runs on Vert.x).

In the same way Vert.x makes it easier to learn a new programming language. You don't have to learn both a language and a new platform (e.g. Ruby and Rails) from scratch. The internal concepts of Vert.x are the same, even if you write verticles in different languages. That means you just have to focus on the new language, and not the whole platform.

Finally, if you choose to change language, Vert.x gives you the freedom to make a slow transition from one language to another. You can keep all your old code and still use it in the same application. You can then write new verticles in the new language, as well as slowly rewrite old verticles in the new language.

Vertx. 3.0 and Beyond

This tutorial is based on Vert.x 3.0 . As new versions of Vert.x are released I will update this tutorial. If you find any discrepancies, please let me know.

This Tutorial is a Supplement the Vert.x Documentation

Vert.x has a pretty good documentation already. Just rewriting that documentation would be stupid. Instead I will attempt to dive deeper into the core concepts, to better convey how a reactive platform works in general, and how the Vert.x version of a reactive platform looks. However, a certain amount of overlap with the Vert.x documentation is unavoidable if this tutorial is to be useful as a standalone resource.

I will also be explaining how Vert.x is different from Java EE and the traditional shared state concurrency model which is predominant in Java EE and Java in general. And, over time I may compare Vert.x to other reactive platforms like RxJava or Akka etc. (when I get around to studying those platforms).

Jakob Jenkov

Copyright  Jenkov Aps
Close TOC