https://bit.ly/JakartaOne
https://bit.ly/JakartaOne
https://bit.ly/JakartaOne
https://bit.ly/JakartaOne
https://bit.ly/JakartaOne
https://bit.ly/JakartaOne
Build a new Project
mvn io.quarkus:quarkus-maven-plugin:0.21.2:create 
-DprojectGroupId=com.marcusbiel 
-DprojectArtifactId=quarkus-demo 
-DclassName="com.marcusbiel.GreetingResource" 
-Dpath="/hello"
https://bit.ly/JakartaOne
Build the Native Docker Image
cd quarkus-demo
mvn package -Pnative -Dnative-image.docker-build=true
https://bit.ly/JakartaOne
https://bit.ly/JakartaOne
https://bit.ly/JakartaOne
https://bit.ly/JakartaOne
Build the Native Docker Image
docker build -f src/main/docker/Dockerfile.native -t
quarkus-demo/demo .
docker run -i --rm -p 8080:8080 quarkus-demo/demo
https://bit.ly/JakartaOne
Run the Image on Kubernetes
kubectl run quarkus-demo --image=quarkus-demo/demo
--port=8080 --image-pull-policy=IfNotPresent
https://bit.ly/JakartaOne
Expose the Service
kubectl expose deployment quarkus-demo --type=NodePort
https://bit.ly/JakartaOne
Access the Service
export URL="$(minikube service quarkus-demo --url)"
curl $URL/hello && echo
https://bit.ly/JakartaOne
Scaling Pods
watch kubectl get pods
kubectl scale deployment quarkus-demo --replicas=3
https://bit.ly/JakartaOne
Get the Route URL
export URL="http://$(oc get route | grep quarkus-demo | awk
'{print $2}')"
echo $URL
curl $URL/hello && echo
https://bit.ly/JakartaOne
Scaling Pods
watch oc get pods
oc scale dc/quarkus-demo --replicas=3
https://bit.ly/JakartaOne
https://bit.ly/JakartaOne
Creating a Project from Scratch
mvn io.quarkus:quarkus-maven-plugin:0.21.2:create
https://bit.ly/JakartaOne
Quarkus on HotspotVM
mvn package
cd target
du -sh *
java -jar jakarta-one-1.0-SNAPSHOT-runner.jar
ps ax -o pid,rss,command | numfmt --header --from-unit=1024
--to=iec --field 2 | grep -v grep | grep jakarta-one
https://bit.ly/JakartaOne
application.properties
quarkus.datasource.url=jdbc:postgresql://localhost:5432/quarkusd
b
quarkus.datasource.driver=org.postgresql.Driver
quarkus.datasource.username=developer
quarkus.datasource.password=developer
quarkus.hibernate-orm.database.generation=drop-and-create
quarkus.http.port=8080
quarkus.http.test-port=8083
com.marcusbiel.HelloClient/mp-rest/url=http://192.168.99.103:31420
https://bit.ly/JakartaOne
List Extensions
mvn quarkus:list-extensions
https://bit.ly/JakartaOne
Add Extensions
mvn quarkus:add-extensions
-Dextensions=quarkus-hibernate-orm-panache,quarkus-jdbc-pos
tgresql,quarkus-resteasy-jsonb,quarkus-rest-client
https://bit.ly/JakartaOne
DeveloperResource
package com.marcusbiel;
@Path("/developers")
public class DeveloperResource {
@Path("/hello")
@GET
@Produces(MediaType.TEXT_PLAIN)
public String hello() {
return "hello";
}
}
https://bit.ly/JakartaOne
pom.xml
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-hibernate-orm-panache</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-jdbc-postgresql</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-resteasy-jsonb</artifactId>
</dependency>
https://bit.ly/JakartaOne
pom.xml
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-smallrye-fault-tolerance</artifactId>
</dependency>
<dependency>
<groupId>io.quarkus</groupId>
<artifactId>quarkus-rest-client</artifactId>
</dependency>
https://bit.ly/JakartaOne
Developer
package com.marcusbiel;
@Entity
public class Developer extends PanacheEntity {
private String name;
public static Developer of(String name) {
return new Developer(name);
}
public String getName() {
return name;
}
private Developer(String name) {
this.name = name;
}
private Developer() {
//Panache only
}
}
https://bit.ly/JakartaOne
Quarkus Developer Mode
mvn compile quarkus:dev
https://bit.ly/JakartaOne
DeveloperResource
package com.marcusbiel;
@GET
@Produces(MediaType.APPLICATION_JSON)
public List<Developer> developers() {
return Developer.listAll();
}
@Path("/new/{name}")
@GET
@Produces(MediaType.APPLICATION_JSON)
@Transactional
public Developer newDeveloper(@PathParam("name") String name) {
Developer developer = Developer.of(name);
developer.persist();
return developer;
}
https://bit.ly/JakartaOne
HelloClient
package com.marcusbiel;
@RegisterRestClient
public interface HelloClient {
@Path("/hello")
@GET
@Produces(MediaType.TEXT_PLAIN)
String hello();
}
https://bit.ly/JakartaOne
DeveloperResource
package com.marcusbiel;
@Path("/developers")
public class DeveloperResource {
@Inject
@RestClient
private HelloClient helloClient;
@Path("/hello")
@GET
@Produces(MediaType.TEXT_PLAIN)
@Fallback(fallbackMethod = "onFallback")
public String helloWorld() {
return helloClient.hello();
}
private String onFallback() {
return "Hallo Stuttgart!";
}
} https://bit.ly/JakartaOne
 Turbocharged Java with Quarkus | JakartaOne Livestream

Turbocharged Java with Quarkus | JakartaOne Livestream