How to implement non blocking REST web service using Vert.x
<p>I am new into Vert.x. I followed Vert.x documents and some tutorials.But I have confused what is the correct way to implement non blocking REST web service using Vert.x. I found this article <a href="https://community.oracle.com/docs/DOC-918126re" rel="nofollow">Develop Non-Blocking Web Applications in Java</a> and this contain a example to implementing Non-Blocking Web Applications using Vert.x.</p>

<p>This code block contain sending a message to a another Vertical(<strong>"todoService":TodoServiceVerticle</strong>).</p>

<pre><code>JsonObject command = new JsonObject();

command.putString("action","findOne").
putNumber("id",Long.valueOf(request.params().get("id")));

String address = "todoService";

vertx.eventBus().send(address, command, (Message&lt;JsonObject&gt; message)-&gt; {
    JsonObject item = message.body();
    String payload = item.encode();
    request.response()
       .putHeader("content-type", "application/json")
       .end(item);
});
</code></pre>

<p>This is the <strong>"todoService":TodoServiceVerticle</strong> Vertical. </p>

<pre><code>public class TodoServiceVerticle extends Verticle{

    /** Initializes the verticle at the start-up */
    @Override public void start() {   
        // Initialize the verticle
        vertx.eventBus().registerHandler("todoService", this::onMessage);
    }

    private void onMessage(Message&lt;JsonObject&gt; message) {
        JsonObject command = message.body();           
        // Only "findOne" is supported in this example 
        assert ("findOne".equals(command.getString("action")));         
        Long id = command.getLong("id");
        Todo item = findOneById(id);
        JsonObject payload = toJson(item);
        message.reply(payload);
    }
}
</code></pre>

<p>in this example the <strong>Server</strong> is running on a one Thread.All the http request are coming to the same thread.The <strong>TodoServiceVerticle</strong> is running in a different Thread.</p>

<p>Now my problem is if <strong>TodoServiceVerticle.onMessage()</strong> function contain time consuming task(eg:- DB Operation,Reading a Large File,...),it will block the process.Assume in the same time another user call TodoServiceVerticle.onMessage() but he also have to wait until previous user complete the task.So How to avoid this kind of problem.Thanks.</p>