Vertx - Http Server (Web)

Java Conceptuel Diagram

About

Vertx web Provide APIs to deal with routing, handling of request payloads, etc.

Two HTTP Vertice

We can deploy the code for a HTTP server on the same TCP port twice and not expect any error for either of the instances, since the TCP port will already be in use.

With many web frameworks we would need to choose different TCP ports, and have a frontal HTTP proxy to perform load balancing between the ports.

There is no need to do that with Vert.x as multiple verticles can share the same TCP ports. Incoming connections are simply distributed in a round-robin fashion from accepting threads.

More …:

Snippet

  • Create an HTTP server which simply returns “Hello World!” to each request.
Vertx.vertx().createHttpServer().requestHandler(req -> req.response().end("Hello World!")).listen(8080);

Documentation / Reference







Share this page:
Follow us:
Task Runner