Vert.x application Preview

A small Microservice App using Eclipse Vert.x and Hazelcast IMDG
App Source Code Vert.x Documentation Hazelcast Documentation
...

About this Application

This Project represents a small Microservice App using Eclipse Vert.x and Hazelcast In-Memory Data Grid.

The project is a Maven project, written by Java language and includes 2 modules, the communication between the verticles will be by using Vert.x Event Bus. The modules names:

  • RestVerticle module
  • OrderVerticle module

The maven package will be generating a docker-compose YAML that will contain two containers for the 2 verticles.

Please Note

This page is only a preview for the application I developed.

Backend Development is in my blood, and these days I focus mainly on it.
This is the reason I developed only the server side for this application.

I created this HTML page just for FUN and to make it more accessible and convenient for you.

To see the Microservice Project source code click below:

A Few Words About: Eclipse Vert.x and Hazelcast IMDG

My main purpose working on this app was to learn new skills, this project mainly focused on Eclipse Vert.x and Hazelcast IMDG functionality.

...
A Few Words About...

Eclipse Vert.x

Eclipse Vert.x is a tool-kit for building reactive asynchronous applications on the JVM.
Reactive applications are both scalable as workloads grow, and resilient when failures arise.

Read more →
...
A Few Words About...

Hazelcast

Hazelcast is an open source In-Memory Data Grid (IMDG). It provides elastically scalable distributed In-Memory computing, widely recognized as fast and scalable approach to application performance.

Read more →

A Quick Glance to the Modules

For full information on the project's architecture and to view the source code, you can click here.

Plus, you can take a quick glance at the structure of the 2 modules below:

Link to Source Code on Github
Backend Development is in my blood, this is the reason I developed only the server side for this application.

I created this HTML page just for FUN and to make it more accessible and convenient for you.

To see the Microservice Project source code click below:

Tech Stack
  • Java Language
  • Eclipse Vert.x
  • Vert.x Event Bus
  • Hazelcast
  • Maven
  • Docker
  • Microservice App
  • Asynchronous app
  • HTML
  • CSS
  • Bootstrap 5
  • Json Format
Module Architecture

RestVerticle

Go to Source Code on Github →

This java module will be a Vert.x verticle and will contain:

...
Main Class:
...
main(String[] args)
To run the application in a cluster mode, the main class will use Vert.x implementation of Hazelcast as a cluster manager. This method will generate the hazelcast configuration and set the destination address.
...
getAddress()
This method will use the NetworkInterface to locate and filter the IP addresses. The relevant IP address will be sent back to the main method.
...
RestVerticle class:

First, we will start by creating HTTP Server and Router:
...
start(Promise<Void> promise)
This method starts an HTTP server. The method create a Vert.x HTTP server and then handle requests using the router generated from the createRouter() method (listening to port 8080).
...
createRouter()
This method creates a Vert.x Web Router (the object used to route HTTP requests to specific request handlers). The method will return Vert.x Web Router.

Then, this class will expose a REST API (using Vert.x) with 5 REST methods:
...
GET: greetingHandler(RoutingContext context)
This method greeting the user at the main endpoint.
...
POST: loginHandler(RoutingContext context)
This method will use the RoutingContext interface to get the username and password from the user, and check if the user can be logged in (username and password will be saved in local JSON file). In the background the module should open a session for each user that logged in.
...
POST: logoutHandler(RoutingContext context)
This method will be used to log out from the user session, his session will be destroyed.
...
POST: addOrderHandler(RoutingContext context)
This method will add an order to the user. By using Vert.x Event Bus, the order will be sent to the OrderVerticle module.
...
GET: getOrdersHandler(RoutingContext context)
This method will return all user orders. The request to get the data will be sent by Vert.x Event Bus to the OrderVerticle module.

Extra methods used in this class to support those REST methods:
...
sessionAuth(RoutingContext context)
Helper method to check if users session is permitted.
...
contextResponse(RoutingContext context, String errorValue, String loginValue, Integer httpStatus)
Helper method to print error values in case one of the endpoints collapse, or get runtime error. This method used in other methods exist in this java class, I added it for clean code. 😊

Go to Source Code on Github →
Module Architecture

OrderVerticle

Go to Source Code on Github →

This java module will be a Vert.x verticle and will contain:

...
Main Class:
...
main(String[] args)
To run the application in a cluster mode, the main class will use Vert.x implementation of Hazelcast as a cluster manager. This method will generate the hazelcast configuration and set the destination address.
...
getAddress()
This method will use the NetworkInterface to locate and filter the IP addresses. The relevant IP address will be sent back to the main method.
...
OrderVerticle class:

First, by using Vert.x Event Bus, we will manage requests that received:
...
start(Promise<Void> promise)
This method use Verte.x Event Bus to manage requests received from the RestVertical module. The Event Bus will direct each request to the relevant method.

Then, each request will be performed:
...
addOrder(Message<Object> message, String orderId, String orderName, String orderDate)
This method add new orders to the user existing orders. All the data will be saved in a local JSON file and include: orderID, orderName and orderDate. The response will be sent to the OrderVerticle module.
...
getOrders(Message<Object> message)
This method will return all user orders.
The response will be sent to the OrderVerticle module.

Extra method used in this class to support other methods:
...
messageResponse(Message<Object> message, String errorValue, String insertValue)
Helper method to print error values in case one of the endpoints collapse, or get runtime error. This method used in other methods exist in this java class, I added it for clean code. 😊

Go to Source Code on Github →