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。