This project leverages Quarkus version 1.9.x, the Supersonic Subatomic Java Framework.
It exposes the following RESTful service endpoints using the Apache Camel Quarkus Platform extension:
/validateMembershipXML
: validates a sampleMembership
XML instance through thePOST
HTTP method./health
: returns the Camel Quarkus MicroProfile health checks/metrics
: the Camel Quarkus MicroProfile metrics
- JDK 11 installed with
JAVA_HOME
configured appropriately - Apache Maven 3.6.2+
You can run your application in dev mode that enables live coding using:
./mvnw quarkus:dev
The application can be packaged using ./mvnw package
.
It produces the camel-quarkus-xmlvalidation-api-1.0.0-SNAPSHOT-runner.jar
file in the /target
directory.
Be aware that it’s not an über-jar as the dependencies are copied into the target/lib
directory.
The application is now runnable using java -jar target/camel-quarkus-xmlvalidation-api-1.0.0-SNAPSHOT-runner.jar
.
- Access to a Red Hat OpenShift cluster v3 or v4
- User has self-provisioner privilege or has access to a working OpenShift project
- Login to the OpenShift cluster
oc login ...
- Create an OpenShift project or use your existing OpenShift project. For instance, to create
camel-quarkus
oc new-project camel-quarkus-jvm --display-name="Apache Camel Quarkus Apps - JVM Mode"
- Use either the S2I binary workflow or S2I source workflow to deploy the
Camel-Quarkus-XmlValidation-Api.postman_collection
app as described below.
This leverages the Quarkus OpenShift extension and is only recommended for development and testing purposes.
./mvnw clean package -Dquarkus.kubernetes.deploy=true
[...]
[INFO] [io.quarkus.deployment.pkg.steps.JarResultBuildStep] Building thin jar: /Users/jeannyil/Workdata/myGit/Quarkus/upstream-quarkus-camel-demos/camel-quarkus-xmlvalidation-api/target/camel-quarkus-xmlvalidation-api-1.0.0-SNAPSHOT-runner.jar
[INFO] [io.quarkus.kubernetes.deployment.KubernetesDeploy] Kubernetes API Server at 'https://api.cluster-f7d5.sandbox81.opentlc.com:6443/' successfully contacted.
[...]
[INFO] [io.quarkus.container.image.s2i.deployment.S2iProcessor] Performing s2i binary build with jar on server: https://api.cluster-f7d5.sandbox81.opentlc.com:6443/ in namespace:camel-quarkus.
[...]
[INFO] [io.quarkus.container.image.s2i.deployment.S2iProcessor] Successfully pushed image-registry.openshift-image-registry.svc:5000/camel-quarkus/camel-quarkus-xmlvalidation-api@sha256:3d3d8060f906acb8d942fb28283cbbc344377ab20d982cd1eec2041a8f20f521
[INFO] [io.quarkus.container.image.s2i.deployment.S2iProcessor] Push successful
[INFO] [io.quarkus.kubernetes.deployment.KubernetesDeployer] Deploying to openshift server: https://api.cluster-f7d5.sandbox81.opentlc.com:6443/ in namespace: camel-quarkus.
[...]
- Make sure the latest supported OpenJDK 11 image is imported in OpenShift
oc import-image --confirm openjdk-11-ubi8 \ --from=registry.access.redhat.com/ubi8/openjdk-11 \ -n openshift
- Create the
Camel-Quarkus-XmlValidation-Api.postman_collection
OpenShift application from the git repositoryoc new-app https://github.com/jeanNyil/upstream-quarkus-camel-demos.git \ --context-dir=camel-quarkus-xmlvalidation-api \ --name=camel-quarkus-xmlvalidation-api \ --image-stream="openshift/openjdk-11-ubi8"
- Follow the log of the S2I build
oc logs bc/camel-quarkus-xmlvalidation-api -f
Cloning "https://github.com/jeanNyil/upstream-quarkus-camel-demos.git" ... Commit: 33b40b3149e109557b8587c14d4aaa88cca5a590 (Updated README) Author: Jean Armand Nyilimbibi <jean.nyilimbibi@gmail.com> Date: Mon Sep 7 21:14:41 2020 +0200 [...] Successfully pushed image-registry.openshift-image-registry.svc:5000/camel-quarkus/camel-quarkus-xmlvalidation-api-s2i@sha256:024fcbaf80ec49e5f044f9af96e176e5fb16ba3325e7d6cee5d70c4884289a69 Push successful
- Create a non-secure route to expose the
Camel-Quarkus-XmlValidation-Api.postman_collection
service outside the OpenShift clusteroc expose svc/camel-quarkus-xmlvalidation-api
-
Get the OpenShift route hostname
URL="http://$(oc get route camel-quarkus-xmlvalidation-api -o jsonpath='{.spec.host}')"
-
Test the
/validateMembershipJSON
endpointcurl -w '\n' -X POST -H 'Content-Type: text/xml' \ -d '<?xml version="1.0" encoding="UTF-8"?><p:membership xmlns:p="http://www.github.com/jeanNyil/schemas/membership/v1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><p:requestType>API</p:requestType><p:requestID>5948</p:requestID><p:memberID>85623617</p:memberID><p:status>A</p:status><p:enrolmentDate>2020-09-05</p:enrolmentDate><p:changedBy>JaLiLa</p:changedBy><p:forcedLevelCode>69</p:forcedLevelCode><p:vipOnInvitation>Y</p:vipOnInvitation><p:startDate>2020-09-05</p:startDate><p:endDate>2100-09-05</p:endDate></p:membership>' \ $URL/validateMembershipXML
{ "validationResult" : { "status" : "OK" } }
-
Test the
/health
endpointcurl -w '\n' $URL/health
{ "status": "UP", "checks": [ { "name": "camel-liveness-checks", "status": "UP" }, { "name": "camel-context-check", "status": "UP", "data": { "contextStatus": "Started", "name": "camel-1" } }, { "name": "camel-readiness-checks", "status": "UP" } ] }
-
Test the
/health/live
endpointcurl -w '\n' $URL/health/live
{ "status": "UP", "checks": [ { "name": "camel-liveness-checks", "status": "UP" } ] }
-
Test the
/health/ready
endpointcurl -w '\n' $URL/health/ready
{ "status": "UP", "checks": [ { "name": "camel-readiness-checks", "status": "UP" }, { "name": "camel-context-check", "status": "UP", "data": { "contextStatus": "Started", "name": "camel-1" } } ] }
-
Test the
/metrics
endpointcurl -w '\n' $URL/metrics
[...] # HELP application_camel_context_exchanges_total The total number of exchanges for a route or Camel Context # TYPE application_camel_context_exchanges_total counter application_camel_context_exchanges_total{camelContext="camel-1"} 30.0 [...] # HELP application_camel_route_exchanges_total The total number of exchanges for a route or Camel Context # TYPE application_camel_route_exchanges_total counter application_camel_route_exchanges_total{camelContext="camel-1",routeId="api-doc-route"} 0.0 application_camel_route_exchanges_total{camelContext="camel-1",routeId="common-500-http-code-route"} 0.0 application_camel_route_exchanges_total{camelContext="camel-1",routeId="custom-http-error-route"} 0.0 application_camel_route_exchanges_total{camelContext="camel-1",routeId="validate-membership-xml-route"} 30.0 application_camel_route_exchanges_total{camelContext="camel-1",routeId="xml-validation-api-route"} 30.0 [...]
Testing using Postman
Import the provided Postman Collection for testing: tests/Camel-Quarkus-XmlValidation-Api.postman_collection.json
You can create a native executable using: ./mvnw package -Pnative
.
Or, if you don't have GraalVM installed, you can run the native executable build in a container using: ./mvnw package -Pnative -Dquarkus.native.container-build=true
.
You can then execute your native executable with: ./target/camel-quarkus-xmlvalidation-api-1.0.0-SNAPSHOT-runner
If you want to learn more about building native executables, please consult https://quarkus.io/guides/building-native-image.