Powering Blockchain with Sustainable Energy and Layered Protocol

The advent of Blockchain technology has changed the face of most of the industries, and it has also produced a direct impact on the carbon footprint and energy consumption. Bitcoin and Ethereum…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Quarkus What? Why? and How?

Ultimately I have been reading a lot about this new framework created by RedHat. I remember the first time I heard about it wasn’t clear to me the necessity to use another framework then Spring, where almost everything is made magically, but from the moment that I started going deep in this framework I find out in Quarkus an excellent option in the matter of Microservices and even more to Serverless using java.

What is Quarkus?

Quarkus is a framework build upon the best java libraries and patterns. The mains Quarkus’s goals are to allow faster development and application initializations, being smaller and consuming fewer machine resources. Quarkus born with the idea to be Cloud Native, be used in Microservices and Serverless projects.

The first release 0.0.1 was 12/12/2018 and the latest version is 1.2.0.

Quarkus is Supersonic, Subatomic, hot reloading and container first, which means it was tailored to run in containers.

Why use Quarkus in your projects?

This answer is quite easy when you understand the “whats” question. If you need or want to run your application on a cloud using Docker and/or Serverless, Quarkus is an excellent choice, as the startup time is extremely fast and the memory consumption is optimized. With that said, if you going to use several containers on a cloud service it is essential a good memory management to save money, apart from that, Quarkus has a great features named Panache, which is an ORM framework to execute queries using a different approach, directly from your entity, which allows us to write queries faster. Last but no least Quarkus has hot reloading and also brings observability tools out-of-the-box.

How to start?

In this tutorial, we will create a Rest application with MongoDB. So, let’s open the site and create our project.

After selecting all the required dependencies to our project, click on Generate your application.

To run your new application without any configuration, all you need is to run the following command:

Access your app by the url:

If you see the above page is a signal that we are in the right way.

There is a default url API too.

Now, it is time to create our Rest API. There is something absolutely awesome, at least to me, which is Quarkus allowing us to create Rest API as Spring, using the same code, to achieve this, all we need is adding the spring-web extension.

Before write some code, lets set up our environment, I’ll use MongoDB with docker, to achieve this we just need 2 commands:

Resource with Spring annotations, using extension:

Resource with Rest API default, plain java:

The second provides the swagger out-of-box to test our APIs.

application.properties

In this tutorial, you could see how easy and fast it is to build an application using Quarkus and Mongodb, and also see its benefits compare to the other frameworks out there, to easy your choose in your next ou actual project.

All code is available in my GitHub:

Add a comment

Related posts:

What if Your Life Was an Artwork?

The way you are living your life is influenced by the metaphors you live by. Once you know that, you can deliberately shift them around and have some fun. Is your life a heroic journey of overcoming…

6 Content Marketing Tools Recommended by the Professionals

There are a lot of different content marketing tools out there, with new ones appearing faster than you can keep up. You might be tempted to keep trying new things, but have you chosen the best…

Tujuan Teknologi Ekstrim adalah untuk menciptakan nilai pengguna

Kami sedang dalam perjalanan untuk berpikir dan menuju kerajaan pamungkas era Wiki, sebuah model eksplorasi dan eksekusi. Pada hari-hari awal, ada lebih banyak elemen untuk dieksplorasi dan diuji…