Contents
Quarkus
A fast framework for the cloud and microservices: REST, Panache, dev mode and native builds.
1.Getting started
- What Quarkus isWhy Quarkus exists, how it differs from other Java frameworks and what we will build in this course.
- Creating a projectHow to generate a Quarkus project with the Maven plugin and what lives in its folders.
- Dev mode and Dev UIRunning the application with quarkus:dev, live reload of code and the Dev UI developer console.
2.REST API
- REST endpointsA resource class, the @Path and @GET annotations, HTTP methods and the response type in Quarkus REST.
- Path and query parametersHow to get an id from the address with @PathParam and the values after the question mark with @QueryParam.
- JSON, records and the request bodyHow to return objects as JSON, accept JSON in the body of a POST request and answer with 201 Created.
- CDI: beans, scopes and injectionHow to move logic out of a resource into a service bean and get it with @Inject.
- Configuration and profilesThe application.properties file, reading values with @ConfigProperty, the dev, test and prod profiles and environment variables.
- A group of settings: @ConfigMappingHow to collect settings with a common prefix into one interface and get typo checks at startup.
- Validating inputJakarta Validation annotations on records, @Valid in a resource and a 400 response with a list of errors.
- Handling errorsYour own exceptions and @ServerExceptionMapper handlers that turn an error into a clear JSON response.
3.Database
- A database and Dev ServicesExtensions for Hibernate ORM and the H2 driver, the automatic Dev Services database in dev mode and the database settings for a server.
- Panache entities: active recordThe Post class as a database table through PanacheEntity: reading, saving and deleting without SQL.
- Queries: search, sorting, pagesSimplified Panache queries, sorting with Sort, paging with Page and counting records.
- The Panache repository and commentsThe second Panache style: a plain Comment entity and a CommentRepository bean with data access methods.
- TransactionsThe @Transactional annotation, rolling back changes on an exception and programmatic transactions with QuarkusTransaction.
4.Service features
- The REST client: calling other servicesHow to call another HTTP API through an interface with @RegisterRestClient, configure its address and handle errors of the remote service.
- Tests: @QuarkusTest and RestAssuredHow to start the application in a test, call endpoints with RestAssured, replace the REST client with a mock and run tests continuously.
- Health checks and metricsThe /q/health endpoints for an orchestrator, your own readiness check and Micrometer metrics in the Prometheus format.
- Security basicsUsers and roles in the configuration file, Basic authentication, the @RolesAllowed and @Authenticated annotations, 401 and 403 responses.
- Scheduled tasksThe @Scheduled annotation: running a method every N seconds or by a cron expression, transactions in jobs and the cron format in Quarkus.
5.Build and deploy
- Building and running a jarThe package command, the quarkus-app folder layout, running in the prod profile, settings from the environment and an uber-jar.
- Native buildWhat a native executable is, how it differs from a jar, how to build it with GraalVM or in a container and what its limits are.
- ContainersThe ready-made Dockerfiles from the generator, building and running an image, settings through environment variables and extensions that build images.