Quarkus Enterprise Model
Its time to move on supersonic subatomic version. In today’s world, microservices have to reside within containers and managed by container orchestration system. Quarkus is the new kid on the Java block. It leverages GraalVM to create native executables which perfectly match micro services and serverless architectures.
Container First approach
Quarkus focus is to make applications robust and subatomic. It is built on the container first approach which guarantees faster startup time and low memory utilization. Quarkus optimizes applications using build-time metadata processing, reduction in reflection usage and native image pre-boot techniques.
Quarkus provide first class support for Graal/SubstrateVM and Open JDK hotspot. It focuses not only heap memory but also RSS. RSS (Resident Set Size) is the memory taken up by JVM apart from heap memory to perform the operations. Memory taken by the application is the combination of RSS and heap memory. Container first approach make Quarkus excellent choice for Function-as-a-Service (FaaS).
Building Enterprises Microservices with Quarkus
Let’s explore more by creating our first enterprise microservice with Quarkus. To start the project, you will need.
- Maven 3.6+
- Open JDK 11
- Kafka
- Kong
- Keycloak
- Angular
- Graal VM
- Docker
Initialize a Project
Quarkus provide maven plugin to create project structure and boilerplate code. To generate the boilerplate code:
mvn io.quarkus:quarkus-maven-plugin:1.9.Final:create \
-DprojectGroupId=com.codewithregu \
-DprojectArtifactId=quarkus-microservice \
-DclassName="com.codewithregu.DemoRestResource" \
-Dpath="/demo"\
-Dextensions="resteasy-jackson, hibernate-validator"
This will generate the folder quarkus-microservice with full project structure:
Quarkus Architecture Flow
The enterprise level application must have a Availability, Security, Scalability, Maintainability, Performance, etc. All those features has been implemented in this demo application. If you are planning to propose reactive framework to your customers, this will be one of the best starting point. Please go through full details below.
This full project is divided into below multiple layers.
Front Layer:
Using the Angular framework and connecting to backend system through highly secured communication block.
Security Layer:
KeyCloak — to allow single sign-on with Identity and Access Management aimed at modern applications and services. User access flow will go like this:
Kong — Kong is Orchestration Microservice API Gateway. Kong provides a flexible abstraction layer that , securely manages communication between clients and microservices via API. Kong providing load balancing, logging, authentication, rate-limiting, transformations, and more through plugins.
If you are building for web, mobile or IoT (Internet of Things) you will likely end up needing common functionality to run your actual software. Kong can help by acting as a gateway (or a sidecar) for microservices requests while providing load balancing, logging, authentication, rate-limiting, transformations, and more through plugins.
Business Layer: Each microservice (Quarkus)have individual business logic and internally connected with data stream & database layer.
Tracing System & Log Layer: Each microservice rest call will be traced by Jaeger & log details analyzed by using Kibana system.
Data Analytics & Visualization: Final processed data published in Grafana. It provides charts, graphs, and alerts for the web when connected to supported data sources.
Once application setup completed, please run all the service. The below 43 services running together make this application a big success.
Data Visualizations:
All the services are up & running and below are the application data results:
Grafana UI: http://13.68.150.47:3000/d/fr73mTtGk/quarkus-dashboard1
KeyCloak Authentication service:
Keyclock with Angular & REST service:
Order Service:
Product & Category Service:
Notification Service:
Customer Service:
Jaeger Traces:
Conclusion
It is still early days for Qurakus and there is still a lot to implement and integrate. I showed you how to build a secure stateless application using Angular and quarkus with secured services. You can use follow a similar pattern with any other frontend frame/library and Quarkus as backend. With the Microprofile and all the top-notch framework support, Quarkus could become the top choice for developing reactive framework in Java.