Vert.x is a toolkit for building reactive applications on the JVM.
For more information about vert.x please read the previous article from here.
Following is a simple http Server implemented using vert.x to understand the nature of vert.x applications.
The code is self explanatory.
To run the above http server, you need vert.x installed and setup properly.
To start the server, open a terminal or a command promt and run the following command.
vertx run Server.java
After you run the above command you will get a message saying 'Succeeded in deploying verticle'.
If you get any errors, please check your vert.x installation.
Now your server is running and waiting for requests to come.
Note that the above server is implemented to handle GET requests only. It listens to the port 8500.
As line 28 needs a parameter called "name", our GET request should include a name parameter.
Now open your browser, paste the below url and hit enter. For 'yourname', you can give anything.
http://localhost:8500/?name=yourname
Now you've used successfully used vert.x to build a server.
This server can handle multiple clients at the same time although in the code we never do anything about it. And we don't have to worry about synchronization or deadlocks.
This is the speciality of vert.x.
This same server can be built using javaScript, ruby Groovy or Python to run on JVM.
More examples can be found in the official github repository of vert.x.
Subscribe to:
Post Comments (Atom)
Optimized quick sort
In the previous article we discussed about quick sort algorithm. In this article we are going to discuss about further optimizing quick sor...
-
Graph A graph ‘G’ is defined as G = (V, E) Where V is a set of all vertices and E is a set of all edges in the graph. Example In the...
-
What is Vert.x ? Vert.x is a toolkit for writing scalable, polyglot, reactive applications which run on the JVM. Vert.x is similar to...
-
Vert.x is a toolkit for building reactive applications on the JVM. For more information about vert.x please read the previous article from...
No comments:
Post a Comment