Java云原生-Micronaut Quarkus SpringNative

 
Redhat提供的Java云原生开发的图书
https://developers.redhat.com/e-books/modernizing-enterprise-java
https://developers.redhat.com/e-books/quarkus-spring-developers

Quarkus

https://quarkus.io/guides/
近几年由于云原生技术的普及,越来越多的用户开始使用容器来运行微服务应用。微服务架构的引入,使我们的服务颗粒度变得越来越小,轻量且能快速启动的应用能够更好的适应容器化环境。 以我们目前常规的Spring Boot应用来说,一般Restful服务的jar包大概是30M左右,如果我们将JDK以及相关应用打包成docker镜像文件大概是140M左右。而常规的Go语言的可执行程序生成镜像包一般不会超过50M。如何让臃肿的Java应用瘦身使他易于容器化,成为Java应用云原生化需要解决的问题。
红帽开源的Quarkus项目,借助开源社区的力量,通过对业界广泛使用的框架进行了适配,并结合云原生应用的特点,提供了一套端到端的Java云原生应用解决方案。虽然开源时间较短,但是生态方面也已经达到可用的状态,自身包含扩展框架,已经支持像Netty、Undertow、Hibernate、JWT等框架,足以用于开发企业级应用,用户也可以基于扩展框架自行扩展。
Quarkus定位为GraalVM*和OpenJDK HotSpot量身定制的一个Kurbernetes Native Java框架。
*GraalVM:JVM为了提升效率,借助JIT及时编译技术对解释执行的字节码进行局部优化,通过编译器生成本地执行代码提升应用执行效率。GraalVM是Oracle实验室开发的新一代的面向多种语言的JVM即时编译器,在性能以及多语言互操作性上有比较好的表现。与Java HotSpot VM相比,Graal借助内联,逃逸分析以及推出优化技术可以提升2至5倍的性能提升。
In March of 2019, after more than a year of internal development, Quarkus was introduced to the open source community. culminating in a 1.0 release within the open source community in October 2019. with a 2.0 community release in June 2021.
Among the specifications and technologies underlying Quarkus are Eclipse MicroProfile, Eclipse Vert.x, Contexts & Dependency Injection (CDI), Jakarta RESTful Web Services (JAX-RS), the Java Persistence API (JPA), the Java Transaction API (JTA), Apache Camel, and Hibernate, just to name a few.
Quarkus is also an ahead-of-time compilation (AOT) platform, optimizing code for the JVM as well as compiling to native code for improved performance. All of the underlying technologies are AOT-enabled, and Quarkus continually incorporates new AOT-enabled technologies, standards, and libraries.

Red Hat 被称为“微服务特性(microservicility)”的内容

https://baijiahao.baidu.com/s?id=1714420255480846215&wfr=spider&for=pc
https://www.infoq.com/articles/microservicilities-quarkus/
Kubernetes 只能覆盖其中的三个
Quarkus 集成了 MicroProfile 规范,将企业级 Java 生态系统转移到了微服务架构中。在下图中,我们可以看到构成 MicroProfile 规范的所有 API。其中有些 API 是基于 Jakarta EE(也就是以前的 Java EE)规范的,比如 CDI、JSON-P 和 JAX-RS,其他的则是由 Java 社区开发的。
 

Start

https://code.quarkus.io/
 
https://mvnrepository.com/artifact/io.quarkus/quarkus-maven-plugin
mvn io.quarkus:quarkus-maven-plugin:2.9.0.Final:create \
-DprojectGroupId=com.redhat.cloudnative \
-DprojectArtifactId=inventory-quarkus \
-DprojectVersion=1.0.0-SNAPSHOT \
-DclassName="com.redhat.cloudnative.InventoryResource" \
-Dextensions="quarkus-resteasy,quarkus-junit5,rest-assured,quarkus-resteasy-jsonb,quarkus-hibernate-orm-panache,quarkus-jdbc-h2"
 

Quarkus vs Spring

Quarkus-For-Spring-Developers-Red-Hat
https://github.com/quarkus-for-spring-developers/examples
 
Quarkus
Spring
starter
https://code.quarkus.io/
https://start.aliyun.com/
https://start.spring.io/
     

Common Quarkus extensions

Maven quarkus:list-extensions
Quarkus extension
Spring Boot Starter
quarkus-resteasy-jackson
spring-boot-starter-web
spring-boot-starter-webflux
quarkus-resteasy-reactive-jackson
spring-boot-starter-web
spring-boot-starter-webflux
quarkus-hibernate-orm-panache
spring-boot-starter-data-jpa
quarkus-hibernate-orm-rest-data-panache
spring-boot-starter-data-rest
quarkus-hibernate-reactive-panache
spring-boot-starter-data-r2dbc
quarkus-mongodb-panache
spring-boot-starter-data-mongodb
spring-boot-starter-data-mongodb-reactive
quarkus-hibernate-validator
spring-boot-starter-validation
quarkus-qpid-jms
spring-boot-starter-activemq
quarkus-artemis-jms
spring-boot-starter-artemis
quarkus-cache
spring-boot-starter-cache
quarkus-redis-client
spring-boot-starter-data-redis
spring-boot-starter-data-redis-reactive
quarkus-mailer
spring-boot-starter-mail
quarkus-quartz
spring-boot-starter-quartz
quarkus-oidc
spring-boot-starter-oauth2-resource-server
quarkus-oidc-client
spring-boot-starter-oauth2-client
quarkus-smallrye-jwt
spring-boot-starter-security

Spring迁移到Quarkus的工具

It can analyze an existing Spring Boot application and offer suggestions for utilizing the Quarkus
Spring Extensions best to migrate the application to Quarkus.
https://developers.redhat.com/products/mta/overview

Micronaut

https://micronaut.io/
https://launch.micronaut.io
Object Computing的一个团队开始重新思考如何从头开始设计 Java 框架。于是Micronaut框架诞生了,这是一个采用了不同做法的 Java 框架,它通过使用 Java 注释将框架的组装计算工作所转移到了编译阶段。这完全消除了传统 Java 框架使用的反射、运行时生成代理和复杂的动态类加载。
2018 年 4 月,Micronaut 框架首次公开发布。
 

Spring Native

https://docs.spring.io/spring-native/docs/current/reference/htmlsingle/
https://start.spring.io/
 

Eclipse Microprofile

https://start.microprofile.io
Eclipse MicroProfile 是一个 Java 微服务开发的基础编程模型,它致力于定义企业 Java 微服务规范,MicroProfile 提供指标、API 文档、运行状况检查、容错、JWT、Open API 与分布式跟踪等能力,使用它创建的云原生微服务可以自由地部署在任何地方,包括 Service Mesh 架构,如 Istio。
posted @ 2022-06-05 15:02  2012  阅读(551)  评论(0编辑  收藏  举报