{"id":20173267,"url":"https://github.com/teedjay/playground-quarkus","last_synced_at":"2025-07-02T02:03:56.232Z","repository":{"id":73156885,"uuid":"177427757","full_name":"teedjay/playground-quarkus","owner":"teedjay","description":"Playing around with MicroProfile using Quarkus.io","archived":false,"fork":false,"pushed_at":"2019-06-21T13:34:24.000Z","size":132,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-03T04:41:54.555Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Java","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/teedjay.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-03-24T14:44:28.000Z","updated_at":"2019-06-21T13:34:26.000Z","dependencies_parsed_at":"2023-02-26T22:15:46.694Z","dependency_job_id":null,"html_url":"https://github.com/teedjay/playground-quarkus","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/teedjay/playground-quarkus","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teedjay%2Fplayground-quarkus","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teedjay%2Fplayground-quarkus/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teedjay%2Fplayground-quarkus/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teedjay%2Fplayground-quarkus/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/teedjay","download_url":"https://codeload.github.com/teedjay/playground-quarkus/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/teedjay%2Fplayground-quarkus/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":263061405,"owners_count":23407606,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-14T01:34:34.244Z","updated_at":"2025-07-02T02:03:56.202Z","avatar_url":"https://github.com/teedjay.png","language":"Java","funding_links":[],"categories":[],"sub_categories":[],"readme":"# playground-quarkus\nPlaying around with MicroProfile using Quarkus.io.\n\nMost tests are in the basic testing project, but scenarios that need external services \nsuch as database and queues are located in separate sub-projects with instructions on \nhow to start pre-requsites using Docker.\n\n- [Basic Quarkus Testing](quarkus-basics/README.md)\n- [Kafka with Quarkus](quarkus-kafka/README.md)\n- [Mongo with Quarkus](quarkus-mongo/README.md)\n\n## TODO\nThese are the things I want to test with Quarkus.\n- [x] Run with Java 11, test with JUnit5 + RestAssured \n- [ ] Remote developer mode (hot reload in container)\n- [x] JAX-RS : Simple API with JSON (JSON-B)\n- [x] JAX-RS : Simple API with XML (JAX-B)\n- [x] JAX-RS : ExceptionMapper\n- [x] JSON-P : JsonPatch\n- [x] CDI : Scoped Injection\n- [x] CDI : Using @Alternative implementations for mocking\n- [x] MicroProfile configuration\n- [x] MicroProfile OpenAPI (annotating with own documentation)\n- [x] MicroProfile Health (with custom health check)\n- [x] MicroProfile Metrics (with custom metrics)\n- [x] MicroProfile JWT (with Keycloak)\n- [x] MicroProfile TypeSafe REST Client\n- [ ] MicroProfile FaultTolerance\n- [x] MicroProfile Reactive Messaging \u0026 Streams (using Kafka extension)\n- [x] Add SwaggerUI start page at http://localhost:8080/\n- [x] MongoDB (needs a MongoDB running on default port)\n- [x] Dockerfile for executable jar (openjdk11)\n- [x] Native executable in Docker container (needs Java 8)\n- [ ] Native executable using GraalVM on MacOS (worked earlier using java 8)\n- [x] Extension : Scheduler (triggers Kafka messages)\n- [x] Extension : Panache (database using Panache with JTA and JPA/JDBC)\n- [x] Extension : Camel\n- [ ] Extension : Kotlin\n- [x] Extension : Mailer\n- [x] Extension : Validation\n- [x] Extension : Undertow (Reverse Proxy and Predicates)\n- [x] Extension : Kafka (Reactive Messaging \u0026 Streams)\n- [x] Extension : Vert.x (EventBus and Async Messaging between beans)\n- [ ] Extension : Reactive Postgres Client\n- [x] Others : Uploading multipart/form-data using JAX-RS (with RestEASY MultipartFormDataInput plugin)\n- [ ] Bug : UsersResourceTest is disabled (does not run when quarkus-smallrye-openapi is included)\n\n## Some comments ...\n\u003e Doesn't require JAX-RS application (@ApplicationPath) \u003cbr/\u003e\n\u003e Doesn't require @Inject on config (@ConfigProperty) \u003cbr/\u003e\n\u003e Config using resources/application.properties or resources/META-INF/microprofile-config.properties\n\u003e Web pages in META-INF/resources (no webapp) \u003cbr/\u003e\n\u003e Debugger works nice from IntelliJ (`Run -\u003e Attach to Process`) \u003cbr/\u003e\n\n## Pre-requisite ...\nI'm using Open JDK 11 with Maven 3.5 and MongoDB + Kafka running on default ports. \n```\n$ java -version\nopenjdk version \"11.0.2\" 2019-01-15\nOpenJDK Runtime Environment AdoptOpenJDK (build 11.0.2+9)\nOpenJDK 64-Bit Server VM AdoptOpenJDK (build 11.0.2+9, mixed mode)\n\n$ mvn -version\nApache Maven 3.5.4 (1edded0938998edf8bf061f1ceb3cfdeccf443fe; 2018-06-17T20:33:14+02:00)\nMaven home: /usr/local/Cellar/maven/3.5.4/libexec\n```\n\n## Create a new empty project\nCreate a new folder and run the command in there.\n```\nmvn io.quarkus:quarkus-maven-plugin:0.17.0:create\n```\n\n## Note on MP-JWT and groups claim\nThe MP-JWT decodes the JWT and use the `groups` claim to select `roles` for RBAC.  This mean that you \nactually need a `group` claim  in the JWT token even if you do not actually use @RolesAllowed for RBAC\nin you code.  If your JWT doesn't contain `groups` claim - Quarkus will throw a Null Pointer Exception.\n\nIf you use KeyCloak as your OIDC server your `groups` are *not* mapped into claims by default.  You\ncan manually add a client mapper for \"User Realm Role\" into \"Token Claim Name\" `groups` (for access-tokens when\nusing service accounts) or you  could map the \"Group Membership\" (when using ID-tokens and direct access grants).\n\nGet Access Token (using Service Account)\n```\nMYCLIENTCREDENTIALS = base64(\"client_id:client_secret\")\n\ncurl -X POST 'https://localhost:9443/auth/realms/quarkus/protocol/openid-connect/token' \\\n-H \"Content-Type: application/x-www-form-urlencoded\" \\\n-H \"Authorization: Basic MYCLIENTCREDENTIALS\" \\\n-d 'grant_type=client_credentials' \\\n| jq -r '.access_token'\n```\n\nGet ID Token (using Direct Access Grants)\n```\ncurl -X POST 'https://localhost:9443/auth/realms/quarkus/protocol/openid-connect/token' \\\n-H \"Content-Type:application/x-www-form-urlencoded\" \\\n-d \"scope=openid\" -d \"grant_type=password\" \\\n-d \"client_id=CLIENTID\" -d \"client_secret=CLIENTSECRET\" \\\n-d \"username=USERNAME\" -d \"password=PASSWORD\" \\\n| jq -r '.id_token'\n```\n\n## URL's to check out\nOur own welcome html page :\n- SwaggerUI : http://localhost:8080/\n\nA number of built-in pages :\n- SwaggerUI : http://localhost:8080/swagger-ui\n- OpenAPI : http://localhost:8080/openapi \n- Metrics : http://localhost:8080/metrics\n- Metrics : http://localhost:8080/metrics/application\n- Health : http://localhost:8080/health\n\n```\ncurl http://localhost:8080/hello\ncurl -X POST -H \"Content-Type: text/plain\" -d \"teedjay\" http://localhost:8080/hello\ncurl http://localhost:8080/mongo\n```\n\n## Commands to use\n```\n# clean and remove old artificts\nmvn clean\n\n# compile and run in dev mode (hot reload and debugging by default on port 5005)\nmvn compile quarkus:dev\n\n# build from scratch and run all tests\nmvn clean test\n\n# create runnable artifacts (SwaggerUI on http://localhost:8080/)\nmvn clean package\njava -jar target/quarkus-1.0.0-SNAPSHOT-runner.jar\n\n# list all Quarkus extensions that can be used in the pom.xml\nmvn quarkus:list-extensions\n```\n\n## Running in Docker\nRun the following from the root of this project.\n\u003e NOTE : The `mongodb.url` must point to the host running MongoDB (localhost is inside container and cannot be used)\n```\nmvn clean package\n\ndocker build -t my-java-app .\ndocker run -it --rm --name my-running-app -p 8080:8080 -e mongodb.url=mongodb://192.168.0.2:27017 my-java-app\n\nopen http://localhost:8080/\n```\n\n## Running as Native code in Linux Container\nUsing the swd847/centos-graal-native-image-rc13:latest docker image to build native linux binary.\n\nBefore we can build, edit the `pom.xml` and use `1.8` as the Java version instead of `11`.\nWe also need to skip test when building as some use Java 11 features.\n```\nmvn clean package quarkus:native-image -Dnative-image.docker-build=true -Dmaven.test.skip=true\n```\nThen build docker image with linux binary and path to SunEC native HTTPS libaray.\n```\ndocker build . -t native-test -f Dockerfile.native-code\n```\nNow you can run a new Docker container with the binary.\n```\ndocker run --rm -p 8080:8080 -e hello.message=RunningNative -e mongodb.url=mongodb://192.168.0.8:27017 -e userservice.url=https://jsonplaceholder.typicode.com/ native-test\n```\n\n## Running as Native code on MacOS\nQuarkus is built to support Ahead Of Time compilation and running on the GraalVM / SubstrateVM.\nThis is why the ArC CDI implemtation is not 100% CDI spec compliant.\n\nI used `graalvm-ce-1.0.0-rc14` and Quarkus 0.12.0 to compile an earlier version of this project on my iMac with Java 8.\n```\n# make sure GraalVM is installed\nteedjay$ java -version\nopenjdk version \"1.8.0_202\"\nOpenJDK Runtime Environment (build 1.8.0_202-20190206132754.buildslave.jdk8u-src-tar--b08)\nOpenJDK GraalVM CE 1.0.0-rc14 (build 25.202-b08-jvmci-0.56, mixed mode)\n\n# make sure $GRAALVM_HOME is set correctly\nteedjay$ echo $GRAALVM_HOME\n/Library/Java/JavaVirtualMachines/graalvm-ce-1.0.0-rc14/Contents/Home\n\n# NOTE : set java versions in pom.xml back to 1.8 before compiling\n# NOTE : some tests use Java 11 features - make sure to skip tests\nteedjay$ mvn clean package quarkus:native-image -Dmaven.test.skip=true\n\nteedjay$ ./target/quarkus-1.0.0-SNAPSHOT-runner\n2019-03-24 21:16:49,095 INFO  [io.quarkus] (main) Quarkus 0.12.0 started in 0.006s. Listening on: http://[::]:8080\n\nteedjay$ java -jar target/quarkus-1.0.0-SNAPSHOT-runner.jar\n2019-03-24 21:26:47,600 INFO  [io.sma.ope.api.OpenApiDocument] (main) OpenAPI document initialized: io.smallrye.openapi.api.models.OpenAPIImpl@43c1b556\n2019-03-24 21:26:48,128 INFO  [io.quarkus] (main) Quarkus 0.12.0 started in 0.729s. Listening on: http://[::]:8080\n2019-03-24 21:26:48,131 INFO  [io.quarkus] (main) Installed features: [cdi, resteasy, resteasy-jsonb, smallrye-health, smallrye-metrics, smallrye-openapi]\n\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteedjay%2Fplayground-quarkus","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fteedjay%2Fplayground-quarkus","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fteedjay%2Fplayground-quarkus/lists"}