OpenShift 4.X Application Development - Quarkus Intro
Image Source: https://cloudowski.com/articles/honest-review-of-openshift-4

OpenShift 4.X Application Development - Quarkus Intro

According to HackerRank 2020 Developer Skills Report, Java is at the second spot for best-known languages (it lost the crown to JavaScript in 2019). This gets to show that Java is not dead yet and there's still a lot of happenings in the Java ecosystem. However, over the years, Java has put on a lot of weight which makes enterprise Java programs slow to start and large in size. In this article, I talk about Quarkus - a Kubernetes-native Java stack with amazingly fast boot time and incredibly low RSS memory (not just heap size!).

Why Quarkus

Application requirements have changed drastically over the last few years. For any application to succeed in the era of cloud computing, big data or IoT, going reactive is increasingly becoming the architecture style to follow. Quarkus combines both the familiar imperative code and the non-blocking reactive style when developing applications.

Thanks to its stellar startup time and low memory usage, you can implement functions using Quarkus to be used in serverless environments like AWS Lambda or IBM Cloud Functions. You can use any of the Quarkus features in your function and benefit from the fast startup and low memory utilization.

Creating a basic project

No alt text provided for this image

In this step, you will create a straightforward application serving a hello endpoint. To demonstrate dependency injection this endpoint uses a greeting bean. The easiest way to create a new Quarkus project is to click to run the following command:

# This will use the Quarkus Maven Plugin and generate a basic Maven project for you in the getting-started subdirectory

mvn io.quarkus:quarkus-maven-plugin:1.0.0.CR1:create \
    -DprojectGroupId=org.acme \
    -DprojectArtifactId=getting-started \
    -DclassName="org.acme.quickstart.GreetingResource" \

    -Dpath="/hello"

Running the application

First, change to the directory in which the project was created: cd /root/projects/quarkus/getting-started and run mvn compile quarkus:dev. You should see:

2020-02-11 01:08:41,121 INFO  [io.qua.dep.QuarkusAugmentor] (main) Beginning quarkus augmentation
2020-02-11 01:08:42,087 INFO  [io.qua.dep.QuarkusAugmentor] (main) Quarkus augmentation completed in 966ms
2020-02-11 01:08:42,565 INFO  [io.quarkus] (main) Quarkus 1.0.0.CR1 started in 1.784s. Listening on: https://0.0.0.0:8080
2020-02-11 01:08:42,567 INFO  [io.quarkus] (main) Profile dev activated. Live Coding activated.
2020-02-11 01:08:42,567 INFO  [io.quarkus] (main) Installed features: [cdi,
resteasy]

Going to <local web browser>:8080/hello should show hello message.

Live Reload

Now, let's exercise the live reload capabilities of Quarkus. Now, make a change to getting-started/src/main/java/org/acme/quickstart/GreetingResource.java file by changing return "hello"; to return "hola"; on line 14. Don't save, don't recompile or restart anything. Just try to reload the browser and you should see the updated hola message. Wow, how cool is that? Supersonic Subatomic live reload!

Next week, I'll show you how to develop a Quarkus application on OpenShift4.

Dewan A.

Principal Developer Advocate @ Harness | ??: dewanahmed.com

4 年

Resources I'm using: 1. RedHat Developer YouTube videos 2. learn.openshift.com 3. quarkus.io

回复

要查看或添加评论,请登录

社区洞察

其他会员也浏览了