Vert.x JVM Framework. MacOS installation Guide.
Distributed Systems Development A-Z Guide.
Give us a message if you’re interested in Blockchain and FinTech software development or just say Hi at Pharos Production Inc.
Or follow us on Youtube to know more about Software Architecture, Distributed Systems, Blockchain, High-load Systems, Microservices, and Enterprise Design Patterns.
Everyone knows that JVM is fast and its horizontal scalability is a battle-tested feature for many developers. Today we have a zoo of frameworks and libraries available that are waiting for our choice when we start a new project. We can select well known Spring and Hibernate or Play framework. They are good with all imaginable features, but here in Pharos Production, we prefer to try tools that are mature enough but provide some other interesting capabilities than MVC and database connection out of the box. Also, we don’t need to build front end within the back end monolith. Today we have chosen a Vert.x framework for our future project. Our goal — minimize microservices features to only required for the usage, wrap functionality into an interface which comfortable for inter-microservice interaction, make it easily scalable and event-driven. Our messaging layer is Apache Pulsar and it’s awesome in terms of inter-microservice messaging. But also Pulsar’s nature is real-time events. So we want the same characteristics for all other parts of the system. Some microservices will be done with Elixir and Actors-based architecture, but for others, we select Vert.x from the zoo of technologies.
The first thing we want to do is to launch HelloWorld on our local machine. We use MacOS, so let’s install Vert.x on it. Also, we will use Scala. So let’s install Scala and SBT using Brew:
brew install scala
brew install sbt
To check if they work well just type scala and sbt in your terminal.
Now let’s boilerplate a new project from the seed. From command line execute:
sbt new vert-x3/vertx-scala.g8
You should see a newly generated project source now.
Import the project into IDEA. Now the most interesting part. How to make the project runnable from IDEA. Select preferable JDK. On the bottom of the window, you should see a Launcher — a path to sbt-launcher.jar. This jar file sits inside the sbt installation directory.
If you have installed sbt from the brew, you can find Launcher at:
Now continue with the project import and in project tree structure you should see, well, your project. Project setup should go automatically and hassle-free. Don’t forget to click Enable Auto-Import to auto-import libraries into the project structure.
Now it’s time to make this little panel work
Add new Application configuration and name it RunVertx.
Vert.x main class is io.vertx.core.Launcher. Use it to run Verticles. In program arguments add run scala:com.pharosproduction.vertx.HttpVerticle.
Where com.pharosproduction.vertx is a package name selected during project import. And HttpVerticle — one of two classes created for you by scaffolding script.
HttpVerticle is really straightforward. There is only one method startFuture() and the only one thing it does is running a brand new HTTP server with a single GET endpoint — /hello on port 8666.
We’re ready to go! Click the Run button
In browser open http://localhost:8666/hello. And the response is the world!
Thank you for reading!