About
Vert.x is not a framework but a toolkit: the core library defines the fundamental APIs for writing asynchronous networked applications, and then you can pick the useful modules for your application (e.g., database connection, monitoring, authentication, logging, service discovery, clustering support, etc).
Vert.x:
- is based on the Netty project.
- implements the reactor pattern (ie event loop), event-driven, reactive, non-blocking
- is a polyglot framework
Usage
- high volume message
- event processing,
- micro-services,
- API gateways,
- HTTP APIs for mobile applications,
- etc
Concept
Three concepts:
- Vertx - The core instance that allows:
- high availability (HA) support. 1)
- reference to the event bus,
- setting timers,
- calls the handlers using the event loop thread (Reactor pattern)
- verticle - the actors deployed on Vertx
- event bus - the bus that allows verticles to communicate
App
- Verticle
package examples.vertx;
import io.vertx.core.AbstractVerticle;
import io.vertx.core.Future;
public class MyVerticle extends AbstractVerticle {
@Override
public void start(Future<Void> startFuture) {
System.out.println("MyVerticle started!");
}
@Override
public void stop(Future stopFuture) throws Exception {
System.out.println("MyVerticle stopped!");
}
}
- Main
import io.vertx.core.Vertx;
public class VertxApp {
public static void main(String[] args) {
Vertx vertx = Vertx.vertx();
vertx.deployVerticle(new MyVerticle());
}
}