# Open terminator
rm -fr ~/dev/demos/camel-quarkus-demo/my-quarkus-project/
rm ~/dev/demos/camel-quarkus-demo/file.pdf
cd ~/dev/demos/camel-quarkus-demo/
# Split window horizontally
# Tune the zoom (CTRL + scroll 10x)
# Prepare the 'mvnu io.quarkus:quarkus-maven-plugin:1.8.1.Final:create' in top shell
# Prepare 'ps -o rss,cmd $(pgrep -f my-q)' in bottom shell
# Prepare 'watch http :8080/hello' in bottom shell
# Zoom in eclipse editor (CTRL/SHIFT/+ 5 times so that we have ~70 chars per line)
# In eclipse, delete 'my-quarkus-project' from eclipse if any
# Prepare the import of the project in eclipse
# Prepare the slides to be shown when native compilation is running
# Put the printed demo plan behind the main screen
# Configure audio input/output to headset
# Copy paste tiny urls so that we can send it very early
# Configure display on a single screen for Apache CON @Home (conf system offer "all screen", "single window" or "chrome tab")
# Speech: Welcome to this session about Getting started with Camel on Quarkus
# Speech: Senor Software Engineer at Red Hat, Camel contributor
# Speech: Typical camel route, consume message/apply pattern/produce result
# Speech: Quarkus = Kubernetes Java stack tailored for OpenJDK HotSpot and GraalVM
# Speech: Extensions, dev mode, test, jvm & native, build a typical route & compare runtime metrics
# Speech: Ask Apache CON @Home attendees to switch the content presentation to full screen
Otherwise, they will not see the command and code
# Take care of possible lags = audio/video shift, it's worth waiting few seconds so that everyone could see commands output
# Copy paste tiny urls in browser
# https://tinyurl.com/y2twers4 => Camel Quarkus Extensions List
# https://tinyurl.com/y5ocv87h => Building native executable
# https://tinyurl.com/yykp6b54 => Demo source on github
# Pre-requisistes
java --version
mvnu --version
native-image --version (gcc, glibc, zlib)
# Create project skeleton: Keep all default values
mvnu io.quarkus:quarkus-maven-plugin:1.8.1.Final:create
cd my-quarkus-project
# Speech: Typical camel route => Interaction with multiple technologies or framework => quarkus extension
mvnu quarkus:list-extensions
# Speech: Most camel components available, different mode supported, jvm-only vs native => full list on camel website
mvnu quarkus:add-extensions -Dextensions=platform-http,jsonpath,pdf
# Import in eclipse: ~/dev/demos/camel-quarkus-demo/my-quarkus-project
# Speech: Camel Quarkus Bootstrap, a java class extending RouteBuilder ( JAVA & XML dsl supported )
Create MyRouteBuilder class:
public class MyRouteBuilder extends RouteBuilder {
@Override
public void configure() {
from("platform-http:/hello").setBody(constant("Hello From Camel Quarkus !"));
}
}
# Speech: Dev mode = Continuous feedback loop
mvnu quarkus:dev
# Speech: Watch changes and update in the blink of an eye
# Kill the watch as it will pollute startup memory in next steps
watch http :8080/hello
# Add MyRouteBuilderTest:
import io.quarkus.test.junit.QuarkusTest
import static io.restassured.RestAssured.given;
@QuarkusTest
public class MyRouteBuilderTest {
@Test
void getHelloShouldReturnHttp200(){
given().when().get("/hello").then().statusCode(200);
}
}
# Speech: Let's see the test is ok
mvnu clean test
# Then in a second time => build
mvnu install
# We have runner jar in target => this is the JVM Mode
ls target
# Speech: All inclusive disk size ~= runner + lib + java (for java, you'll need at least modules)
# "lib/modules" size ~= openjre11-alpine-image-size - alpine-3.12-image-size (open jre 11.0.9 docker image is based on alpine 3.12)
du -chLs target/my-quarkus-project-1.0-SNAPSHOT-runner.jar target/lib ${JAVA_HOME}/lib/modules
# Speech: Camel boot time / Quarkus boot time
java -jar target/my-quarkus-project-1.0-SNAPSHOT-runner.jar
# Speech: Resident Set Size = everything in RAM in KiB ~= part of shared library + stack + heap that is actually used
ps -o rss,cmd $(pgrep -f my-q)
# Proves that it run
http :8080/hello
# Then show slides while building in native mode (~3 minutes)
mvnu package -P native
# We have a native executable in target => this is the Native Mode
ls target
# Speech: Just enough of application code / third party libs / jdk)
du -chLs target/my-quarkus-project-1.0-SNAPSHOT-runner*
# Speech: Instant startup
target/my-quarkus-project-1.0-SNAPSHOT-runner
# Then rss mem
ps -o rss,cmd $(pgrep -f my-q)
# And finally show it working
http :8080/hello
# Add default message:
# setBody(simple("{{msg}}")). # in route
# camel.default-msg = ItsWorm # in src/main/resources/applications.properties
mvnu quarkus:dev
http :8080/hello
mvnu quarkus:dev -Dmsg=ItsWarm
# Speech: Explains the route logic a bit more
# Speech: It receives an http request with a json body and extract the temperature
# Speech: When the temperature is greater than 30 it issues a message like "It's warm"
# Speech: Otherwise, it issues a message like "It's cold"
# Add some jsonpath logic in route:
# @Override
# public void configure() throws Exception {
# // {room:{temperature:50}}
# from("platform-http:/hello").
# choice().when(jsonpath("$.room[?(@.temperature > 30)]")).
# setBody(simple("{{camel.default-msg}}")).
# otherwise().
# setBody(constant("ItsC old")).
# end();
# }
watch http :8080/hello <<< '{room: {temperature: 30}}'
# Finally, add pdf generation
# .to("pdf:create?fontSize=26");
http :8080/hello <<< '{room : {temperature : 40}}' > test.pdf
firefox test.pdf
# Then run compare.sh
cd ..
# Speech: Now, compare key metrics on different runtimes
# Speech: Same demo on top of Spring Boot, Quarkus JVM Mode and Quarkus Native Mode
# Speech: Estimation of time needed to boot and serve the first request
camel-hellos/compare.sh
# Slides: Show last page
# Speech: This is just a typical route built and tested locally for demo purpose but in the next session Omar may show how to do continuous delivery and deployment on Knative
# Speech: I hope that you now have a better idea of WHY we've created camel-quarkus
# Speech: In a nutshell, it's all about lightweight pattern based integrations running in the cloud
# Speech: Thanks all, time for question, feel free to reach out to the community
# End for now
----------------------------------------------------------------------------------------------------------------------