# Vert.x

> Eclipse Vert.x is *event driven \_and \_non blocking*. This means your app can handle a lot of concurrency using a small number of kernel threads. Vert.x lets your app scale with minimal hardware. -- <http://vertx.io>

Vert.x is an entire toolkit and ecosystem of pluggable modules on top of Netty for building reactive applications on top of the JVM.

Issues with threads that Vert.x with Netty solved: A large block of memory has to be allocated and initialized for the thread stack. System calls need to be made to register the native thread with the host OS. Descriptors needs to be created, initialized and added to JVM internal data structures.

## Hello world

Here are [many use cases](http://vertx.io/docs/) for Vert.x, but lets create hello world app as HTTP server.

Lets create a project in Gradle.

```
plugins {
  id 'java'
  id 'application'
}

ext {
  vertxVersion = '3.5.0'
}

repositories {
  mavenLocal()
  jcenter()
}

version = '1.0.0-SNAPSHOT'
sourceCompatibility = '1.8'

dependencies {
  compile "io.vertx:vertx-core:$vertxVersion"
  compile "io.vertx:vertx-unit:$vertxVersion"
}

mainClassName = 'com.example.demo.App'

task wrapper(type: Wrapper) {
  gradleVersion = '4.0'
}
```

Then we can create runnable class that starts up the server.

```
package com.example.demo;

import io.vertx.core.Vertx;
import io.vertx.core.http.HttpServer;
import io.vertx.core.http.HttpServerOptions;

public class App {

    public static void main(String[] args) {
        Vertx vertx = Vertx.vertx();
        HttpServerOptions options = new HttpServerOptions().setLogActivity(true);

        HttpServer httpServer = vertx.createHttpServer(options);
        httpServer.requestHandler(request -> {
            request.response().end("Hello World");
        });
        httpServer.listen(8888, res -> {
            if (res.succeeded()) {
                System.out.println("Server is now listening!");
            } else {
                System.out.println("Failed to bind!");
            }
        });
    }
}
```

When start the server and execute HTTP request, we get this.

```
$ gradle run
Server is now listening!

$ curl localhost:888
Hello World
```


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ondrej-kvasnovsky-2.gitbook.io/java-handbook/reactive-programming/vertx.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
