This is the 14th day of my participation in Gwen Challenge

Heart like baiyun often comfortable, meaning such as water as things.

In the embrace cloud native – primary Quarkus, a simple understanding of Quarkus. This article continues to learn about cloud native and Quarkus.

Cloud native

Cloud Native was first proposed in “Migration to Cloud Native Application Architecture” in 2015, which summarized five key features of Cloud Native applications:

  1. Twelve factor applications
  2. Micro service
  3. Agile, self-service infrastructure
  4. Collaboration between services based on API
  5. The fragile

The definition of cloud native released by Google in 2018 is:

Cloud native technologies enable organizations to build and run scalable applications in modern and dynamic environments, such as public, private, and hybrid clouds. Representative technologies include containers, service grids, microservices, immutable infrastructure, and declarative apis.

  1. Application containerization
  2. Microservices Oriented architecture
  3. The application supports container scheduling

These technologies enable the construction of loosely-coupled systems that are resilient, easy to manage, and easy to observe. Combined with powerful automation capabilities, these technologies enable engineers to make significant changes to systems easily, frequently, and predictably.

Subsequently, VMware defined cloud native in 2020 as:

“Cloud native is a way to build and run applications that take advantage of the cloud computing software delivery model. When companies build and run applications using cloud-native architectures, they can bring new ideas to market more quickly and respond to customer needs more quickly. . Cloud native applications focus more on how applications are created and deployed. A more important aspect of cloud native is the ability to provide developers with on-demand access to computing power, as well as modern data and application services. Cloud native development is coupled with the concepts of DevOps, continuous delivery, microservices and containers.”

Redhat defines and understands cloud native applications as follows:

Cloud native application development is an approach to building, running, and improving applications based on well-known cloud computing techniques and technologies.

Cloud native applications are collections of independent, small-scale, loosely coupled services designed to provide recognized business value, such as quickly incorporating user feedback for continuous improvement. In short, with cloud native application development, you can accelerate the building of new applications, optimize existing applications, and integrate into cloud native architectures. The goal is to meet the needs of application users as quickly as the enterprise needs them.

Cloud native is a kind of behavior and design concept. In essence, any behavior or method that can improve resource utilization rate and application delivery efficiency on the cloud is cloud native [3].

Cloud native is a way of building and running applications, a set of technical systems and methodologies. CloudNative is a compound word, Cloud+Native. Cloud means that the application resides in the Cloud, rather than a traditional data center; Native applications take the cloud environment into account at the beginning of design. They are designed for the cloud and run in the best position on the cloud, making full use of the flexibility and distributed advantages of the cloud platform. In short, in line with the cloud native architecture application should be: using open source stacks (K8S + Docker) to container, improve flexibility and maintainability based on micro service architecture, using agile methods, enterprise support continued iteration and ops automation, using cloud infrastructure platform to achieve flexibility, dynamic scheduling and optimizing resource utilization. [4].

Image source: Author: Huawei Cloud Developer Community link: juejin.cn/post/684490… The copyright belongs to the author. Commercial reprint please contact the author for authorization, non-commercial reprint please indicate the source.

Quarkus basic use

After theory, let’s move on to Quarkus practice. 内 容 提 要 : Quarkus. IO/Guides/Gett

injection

In Quarkus, Inject is available using @inject. Contexts and Dependency Injection Guide

package org.acme.getting.started;

import javax.inject.Inject;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.Produces;
import javax.ws.rs.core.MediaType;

import org.jboss.resteasy.annotations.jaxrs.PathParam;

@Path("/hello")
public class GreetingResource {
	
    / / injection
	@Inject
	GreetingService service;

    @GET
    @Produces(MediaType.TEXT_PLAIN)
    public String hello(a) {
        return "Hello RESTEasy";
    }
    
    @GET
    @Produces(MediaType.TEXT_PLAIN)
    @Path("/greeting/{name}")
    public String greeting(@PathParam String name) {
        returnservice.greeting(name); }}Copy the code

Development mode

The project is run by executing the command:

./mvnw compile quarkus:dev
Copy the code

Quarkus :dev means we’re running in development mode. Hot update is enabled in development mode.

test

You can use the @Quarkustest annotation to Test classes and the @test annotation method. Then the command line executes:./ MVNW test

@QuarkusTest
public class GreetingResourceTest {

    @Test    
    public void testHelloEndpoint(a) {... }@Test
    public void testGreetingEndpoint(a) {... }}Copy the code

packaging

Execute command:

./mvnw package
Copy the code

Will be generated

  1. Getting started - 1.0.0 - the SNAPSHOT. The jar– Contains only the project’s classes and resources, which are regular artifacts generated by Maven builds – itnotRunnable JARS;
  2. quarkus-appFolder, including an executablequarkus-run.jarFile. This jar is not a reference JAR, so you don’t need to put it inquarkus-app/lib/
  3. If you want to deploy to a container, you should deploy the entirequarkus-appDirectory.
  4. If you simply run the command, you can run the commandjava -jar target/quarkus-app/quarkus-run.jar
  5. If the packaging mode is configured in the configuration filefast-jar, the generated package starts faster and consumes less memory.

[1] What is cloud native

[2] Migrating to cloud native application architectures

[3] The definition of Cloud Native — tutorial

[4] What is cloud native? This time someone finally spoke out – Huawei

[5] How to understand Cloud Native applications? – the Red Hat

[6] an overview of cloud native architecture, which compares SpringCloud and Kubernetes