{{announcement.body}}
{{announcement.title}}

Building Microservices With Red Hat Quarkus

DZone 's Guide to

Building Microservices With Red Hat Quarkus

In this article, we discuss how to get started managing Maven dependencies with Red Hat Quarkus in order to quickly build microservices.

· Microservices Zone ·
Free Resource

Red Hat Quarkus is supersonic, subatomic Java framework for creating cloud native apps and services using the JEE specification. It supports a full project lifecycle, using its own Maven dependency management and build plugin.

For initial development, we are leveraging a JAX-RS based microservice-starter application similar to implementation using Wildfly Swarm.

More about the lifecycle is explained below.

Packaging

Red Hat Quarkus provides its own Maven support to package code and its dependencies, as Uber jar including the container itself. For this, you need to add the following build plugin and application configuration (until the time that a maven property is available).

XML
 




x
16


 
1
<build>
2
 <plugins>
3
   <plugin>
4
     <groupId>io.quarkus</groupId>
5
     <artifactId>quarkus-maven-plugin</artifactId>
6
     <version>${quarkus.version}</version>
7
     <executions>
8
       <execution>
9
         <goals>
10
           <goal>build</goal>
11
         </goals>
12
       </execution>
13
     </executions>
14
   </plugin>
15
  </plugins>
16
</build>



application.properties

Properties files
 




xxxxxxxxxx
1


 
1
quarkus.package.uber-jar=true



You may also like:  DZone Refcardz: Quarkus.

Deployment

Red Hat Quarkus provides multiple embeddable containers that can be used as a dependency. JAX-RS support is provided by a resteasy container.

XML
 




xxxxxxxxxx
1


 
1
<dependency>
2
 <groupId>io.quarkus</groupId>
3
 <artifactId>quarkus-resteasy</artifactId>
4
</dependency>


Launcher

ARed Hat Quarkus container can be launched using multiple options

  • Dev - Just run following Maven goal on project.
Shell
 




xxxxxxxxxx
1


1
mvn quarkus:dev



  • Prod - The Maven package generate a fat jar, which contains a generated main class and JAX-RS application that can be run using plain Java.
Shell
 




xxxxxxxxxx
1


 
1
java -jar java -jar target\microservice-starter-quarkus-1.0.0-runner.jar



The complete example can found here at microservice-starter-quarkus.


Further Reading

Topics:
java ,microservice ,redhat ,quarkus ,tutorial

Opinions expressed by DZone contributors are their own.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}