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...
-
A great amount of reasons exist on why should you use solar panels at home with the money you save on electricity being the primary one. T...
-
This program uses user entered characters(up to 8 characters) to generate all possible combinations of these characters using every charact...
-
You saw it in with gas prices in the summer of 2008; when non-renewable resources like oil, gas and coal become more and more scarce while t...
No comments:
Post a Comment