diff --git a/docs/index.html b/docs/index.html index cf988e1a..a9e7ad59 100644 --- a/docs/index.html +++ b/docs/index.html @@ -450,1583 +450,14 @@

Home of Quarkus Cheat-Sheet

Quarkus (https://quarkus.io/) is a Kubernetes Native Java stack tailored for GraalVM & OpenJDK HotSpot, crafted from the best of breed Java libraries and standards. Also focused on developer experience, making things just work with little to no configuration and allowing to do live coding.

-

In this page you can either read what has been added in each version of the cheat-sheet individually in What’s New in Cheat-Sheet section, see the full cheat-sheet as HTML Quarkus Cheat-Sheet format or download the full cheat-sheet as PDF.

-
-
-
-
-

What’s New in Cheat-Sheet

-
-
-

Version 1.13.0.Final

-
-DevServices -
-
-

When testing or running in dev mode Quarkus can even provide you with a zero config database out of the box. -Depending on your database type you may need docker installed in order to use this feature.

-
-
-

The following open source databases:

-
-
-
    -
  • -

    Postgresql (container)

    -
  • -
  • -

    MySQL (container)

    -
  • -
  • -

    MariaDB (container)

    -
  • -
  • -

    H2 (in-process)

    -
  • -
  • -

    Apache Derby (in-process)

    -
  • -
-
-
-

To use DevServices don’t configure a database URL, username and password, Quarkus will provide the database and you can just start coding without worrying about config.

-
-
-
-
quarkus.datasource.db-kind=mariadb
-%prod.quarkus.datasource.jdbc.url=jdbc:mariadb://db:3306/mydb
-%prod.quarkus.datasource.username=developer
-%prod.quarkus.datasource.password=developer
-
-
-
-

Possible configuration values prefixed with quarkus.datasource:

-
-
-
-
devservices
-
-

If devservices is enabled or not. (default: true)

-
-
devservices.image-name
-
-

The container image name to use instead of the default one.

-
-
devservices.properties
-
-

Generic properties that are added to the database connection URL.

-
-
-
-
-
-
-Quarkus Integration Tests -
-
-

@QuarkusIntegrationTest should be used to launch and test the artifact produced by the Quarkus build. -If the result of a Quarkus build is a JAR then the app is launched as java -jar, if native is launched as ./application, if container image is created (JiB, Docker extensions) is launched as docker run.

-
-
-
-
-Native configuration properties -
-
-

Native configuration properties prefixed with quarkus.native:

-
-
-
-
additional-build-args
-
-

Additional arguments to pass to the build process.

-
-
enable-http-url-handler
-
-

If the HTTP url handler should be enabled. (default: true)

-
-
enable-https-url-handler
-
-

If the HTTPS url handler should be enabled.

-
-
enable-all-security-services
-
-

If all security services should be added to the native image.

-
-
user-language
-
-

Defines the user language used for building the native executable.

-
-
user-country
-
-

Defines the user country used for building the native executable.

-
-
file-encoding
-
-

Defines the file encoding.

-
-
add-all-charsets
-
-

If all character sets should be added to the native image.

-
-
graalvm-home
-
-

The location of the Graal distribution.

-
-
java-home
-
-

The location of the JDK.

-
-
native-image-xmx
-
-

The maximum Java heap to be used during the native image generation.

-
-
debug-build-process
-
-

If the native image build should wait for a debugger to be attached before running.

-
-
publish-debug-build-process-port
-
-

If the debug port should be published when building with docker and debug-build-process. (default: true)

-
-
cleanup-server
-
-

If the native image server should be restarted.

-
-
enable-isolates
-
-

If isolates should be enabled. (default: true)

-
-
enable-fallback-images
-
-

If a JVM based 'fallback image' should be created if native image fails.

-
-
enable-server
-
-

If the native image server should be used.

-
-
auto-service-loader-registration
-
-

If all META-INF/services entries should be automatically registered.

-
-
dump-proxies
-
-

If the bytecode of all proxies should be dumped for inspection.

-
-
container-build
-
-

If this build should be done using a container runtime.

-
-
remote-container-build
-
-

If this build is done using a remote docker daemon.

-
-
builder-image
-
-

The docker image to use to do the image build.

-
-
container-runtime
-
-

The container runtime that is used to do an image based build. (docker, podman)

-
-
container-runtime-options
-
-

Options to pass to the container runtime.

-
-
enable-vm-inspection
-
-

If the resulting image should allow VM introspection.

-
-
full-stack-traces
-
-

If full stack traces are enabled in the resulting image.

-
-
enable-reports
-
-

If the reports on call paths and included packages/classes/methods should be generated.

-
-
report-exception-stack-traces
-
-

If exceptions should be reported with a full stack trace.

-
-
report-errors-at-runtime
-
-

If errors should be reported at runtime.

-
-
enable-dashboard-dump
-
-

Generate the report files for GraalVM Dashboard.

-
-
resources.includes
-
-

A comma separated list of globs to match resource paths that should be added to the native image.

-
-
resources.excludes
-
-

A comma separated list of globs to match resource paths that should exclude to the native image.

-
-
debug.enabled
-
-

If debug is enabled and debug symbols are generated.

-
-
-
-
-
-
-OpenId properties -
-
-

Possible OpenAPI options with quarkus.smallrye-openapi prefix:

-
-
-
-
path
-
-

The path at which to register the OpenAPI Servlet. (default: openapi)

-
-
store-schema-directory
-
-

The generated OpenAPI schema documents will be stored here on build.

-
-
security-scheme
-
-

Add a certain SecurityScheme with config. (basic, jwt, oidc, oauth2Implicit)

-
-
security-scheme-name
-
-

Add a Security Scheme name to the generated OpenAPI document. (default: SecurityScheme)

-
-
security-scheme-description
-
-

Add a description to the Security Scheme. (default: Authentication)

-
-
basic-security-scheme-value
-
-

Add a scheme value to the Basic HTTP Security Scheme. (default: basic)

-
-
jwt-security-scheme-value
-
-

Add a scheme value to the JWT Security Scheme. (default: bearer)

-
-
jwt-bearer-format
-
-

Add a bearer format to the JWT Security Scheme. (default: JWT)

-
-
oidc-open-id-connect-url
-
-

Add a openIdConnectUrl value to the OIDC Security Scheme

-
-
oauth2-implicit-refresh-url
-
-

Add a implicit flow refreshUrl value to the OAuth2 Security Scheme

-
-
oauth2-implicit-authorization-url
-
-

Add an implicit flow authorizationUrl value to the OAuth2 Security Scheme

-
-
oauth2-implicit-token-url
-
-

Add an implicit flow tokenUrl value to the OAuth2 Security Scheme

-
-
-
-
-
-
-JsonbConfig -
-
-

To provide custom JsonBConfig object:

-
-
-
-
@Dependent
-JsonbConfig jsonConfig(Instance<JsonbConfigCustomizer> customizers) {
-    JsonbConfig config = myJsonbConfig(); // Custom `JsonbConfig`
-    for (JsonbConfigCustomizer customizer : customizers) {
-        customizer.customize(config);
-    }
-
-    return config;
-}
-
-
-
-
-
-OpenTelemetry -
-
-

Quarkus integrates with the OpenTelemetry project. -For exporting traces to a Jaeger collector, use the quarkus-opentelemetry-exporter-jaeger extension.

-
-
-
-
-Kubernetes Service Binding -
-
-

Quarkus supports binding services to applications via the Service Binding Specification for Kubernetes.

-
-
-

The following Quarkus extensions support this feature:

-
-
-
    -
  • -

    quarkus-jdbc-mariadb

    -
  • -
  • -

    quarkus-jdbc-mssql

    -
  • -
  • -

    quarkus-jdbc-mysql

    -
  • -
  • -

    quarkus-jdbc-postgresql

    -
  • -
  • -

    quarkus-kafka-client

    -
  • -
  • -

    quarkus-smallrye-reactive-messaging-kafka

    -
  • -
-
-
-
-
./mvnw quarkus:add-extensions
-    -Dextensions="quarkus-kubernetes-service-binding"
-
-
-
-

Datasource configuration part is absent as it is aut-discovered by Quarkus.

-
-
-
-
-RESTEasy Reactive-based REST Client -
-
-

A RESTEasy Reactive-based REST Client extension. -You only need to replace the quarkus-rest-client to quarkus-rest-client-reactive.

-
-
-
-
-
-

Version 1.12.0.Final

-
-Qute Value Resolvers -
-
-

Value resolvers are invoked when evaluating expressions.

-
-
-
-
void configureEngine(@Observes EngineBuilder builder) {
-  builder.addValueResolver(ValueResolver.builder()
-      .appliesTo(ctx -> ctx.getBase() instanceof Long && ctx.getName().equals("tenTimes"))
-      .resolveSync(ctx -> (Long) ctx.getBase() * 10)
-      .build());
-}
-
-
-
-
-
-Qute Content Filter -
-
-

Content filters can be used to modify the template contents before parsing.

-
-
-
-
void configureEngine(@Observes EngineBuilder builder) {
-  builder.addParserHook(new ParserHook() {
-      @Override
-      public void beforeParsing(ParserHelper parserHelper) {
-          parserHelper.addContentFilter(contents -> contents.replace("${", "$\\{"));
-      }
-  });
-}
-
-
-
-
-
-Start multiple test resources concurrently -
-
-

When using multiple QuarkusTestResource you can set parallel attribute to true to start them concurrently.

-
-
-
-
-Running specific tests -
-
-

quarkus.test.profile.tags property can be set to limit test execution of test profiles. -If not set all tests are executed.

-
-
-
-
quarkus.test.profile.tags=test1
-
-
-
-
-
-
-

Version 1.11.0.Final

-
-Trust All -
-
-

You can trust all certificates globally by using quarkus.tls.trust-all=true

-
-
-
-
-Vault Transit Key -
-
-
-
@Inject
-VaultTransitSecretEngine transit;
-
-transit.createKey(KEY_NAME, new KeyCreationRequestDetail().setExportable(true));
-transit.readKey(KEY_NAME);
-transit.listKeys();
-transit.exportKey(KEY_NAME, VaultTransitExportKeyType.encryption, null);
-transit.updateKeyConfiguration(KEY_NAME, new KeyConfigRequestDetail().setDeletionAllowed(true));
-transit.deleteKey(KEY_NAME);
-
-
-
-
-
-Switch/When Qute -
-
-
-
{#switch person.name}
-  {#case 'John'}
-    Hey John!
-  {#case 'Mary'}
-    Hey Mary!
-{/switch}
-
-
-
-
-
{#when items.size}
-  {#is 1} (1)
-    There is exactly one item!
-  {#is > 10} (2)
-    There are more than 10 items!
-  {#else} (3)
-    There are 2 -10 items!
-{/when}
-
-
-
-

Following operators can be used either in when and switch: not, ne, !=, gt, >, ge, >=, lt, <, le, <=, in, ni, !in.

-
-
-
-
-Injectable Logger -
-
-

You can inject logger instance:

-
-
-
-
import org.jboss.logging.Logger;
-import io.quarkus.arc.log.LoggerName;
-
-@Inject
-Logger log;
-
-@LoggerName("foo")
-Logger fooLog;
-
-public void ping() {
-    log.info("Simple!");
-}
-
-
-
-
-
-Additional Configuration Locations -
-
-

You can use smallrye.config.locations property to set additional configuration files.

-
-
-
-
smallrye.config.locations=config.properties
-
-
-
-

or

-
-
-
-
java -jar -Dsmallrye.config.locations=config.properties
-
-
-
-
-
-JBang Maven creator -
-
-

A Maven goal is provided to scaffold a project:

-
-
-
-
mvn io.quarkus:quarkus-maven-plugin:<version>:create-jbang
-
-
-
-
-
-RESTEasy Reactive -
-
-

RESTEasy Reactive is a new implementation of JAX-RS but fully reactive.

-
-
-
-
mvn quarkus:add-extension
-    -Dextensions="quarkus-resteasy-reactive"
-
-
-
-
-
package org.acme.rest;
-import javax.ws.rs.GET;
-import javax.ws.rs.Path;
-@Path("rest")
-public class Endpoint {
-
-    @Path("hello")
-    @GET
-    public String hello(){
-        // executed in event-loop
-        return "Hello, World!";
-    }
-
-    @GET
-    public Uni<Book> culinaryGuide(){
-        // executed in event-loop but not blocking
-        return Book.findByIsbn("978-2081229297");
-    }
-
-    @io.smallrye.common.annotation.Blocking
-    @GET
-    public String blockingHello() throws InterruptedException {
-        // executed in worker-thread
-        return "Yaaaawwwwnnnnnn…";
-    }
-
-}
-
-
-
-
-
-Exclusions in Native compilation -
-
-

By default, no resources are excluded.

-
-
-
-
quarkus.native.resources.excludes = foo/**
-
-
-
-
-
-Flyway Callbacks support -
-
-
-
callbacks
-
-

Comma-separated list of fully qualified class names of Callback implementations.

-
-
-
-
-
-
-Spring Data Rest -
-
-

While users are encouraged to use REST Data with Panache for the REST data access endpoints generation, Quarkus provides a compatibility layer for Spring Data REST in the form of the spring-data-rest extension.

-
-
-
-
./mvnw quarkus:add-extension
-  -Dextensions="spring-data-rest"
-
-
-
-
-
import java.util.Optional;
-import org.springframework.data.repository.CrudRepository;
-import org.springframework.data.rest.core.annotation.RepositoryRestResource;
-import org.springframework.data.rest.core.annotation.RestResource;
-
-@RepositoryRestResource(exported = false, path = "/my-fruits")
-public interface FruitsRepository extends CrudRepository<Fruit, Long> {
-    @RestResource(exported = true)
-    Optional<Fruit> findById(Long id);
-    @RestResource(exported = true)
-    Iterable<Fruit> findAll();
-}
-
-
-
-

The spring-data-jpa extension will generate an implementation for this repository. Then the spring-data-rest extension will generate a REST CRUD resource for it.

-
-
-

The following interfaces are supported:

-
-
-
    -
  • -

    org.springframework.data.repository.CrudRepository

    -
  • -
  • -

    org.springframework.data.repository.PagingAndSortingRepository

    -
  • -
  • -

    org.springframework.data.jpa.repository.JpaRepository

    -
  • -
-
-
-
-
-Dev UI -
-
-

Quarkus adds a Dev UI console to expose extension features.

-
-
-

The Dev UI is available in dev mode only and accessible at the /q/dev endpoint by default.

-
-
-
-
-
-

Version 1.10.0.Final

-
-Add algorithms to hash passwords in embeded mode -
-
-
-
algorithm
-
-

Determine which algorithm to use. Possible values: DIGEST_MD5, DIGEST_SHA, DIGEST_SHA_256, DIGEST_SHA_384, DIGEST_SHA_512, DIGEST_SHA_512_256. (default: DIGEST_MD5)

-
-
-
-
-
-
-Panache MongoDB Rest Data -
-
-

MongoDB REST Data with Panache extension can generate the basic CRUD endpoints for your entities and repositories.

-
-
-
-
./mvnw quarkus:add-extension
-  -Dextensions="mongodb-rest-data-panache"
-
-
-
-

You also need to add the JDBC driver extension and a JSON Marshaller (ie resteasy-jackson).

-
-
-

Then you can define interfaces for defining endpoints:

-
-
-

In case of Active Record pattern:

-
-
-
-
public interface DeveloperResource extends PanacheMongoEntityResource<Developer, Long> {
-}
-
-
-
-

In case of Repository:

-
-
-
-
public interface DeveloperResource extends PanacheMongoRepositoryResource<DeveloperRepository, Developer, Long> {
-}
-
-
-
-
-
-Enabling permissions -
-
-

You can use enabled property (ie quarkus.http.auth.permission.permit1.enabled) to enable the entire permission set.

-
-
-
-
-OpenTracing Kafka Integration -
-
-

Kafka Tracer

-
-
-

Adds a span for each message sent to or received from a Kafka topic.

-
-
-
-
<dependency>
-    <groupId>io.opentracing.contrib</groupId>
-    <artifactId>opentracing-kafka-client<</artifactId>
-</dependency>
-
-
-
-

And configure it:

-
-
-
-
...
-mp.messaging.outgoing.generated-price.topic=prices
-
-# For Produces
-mp.messaging.outgoing.generated-price.interceptor.classes=io.opentracing.contrib.kafka.TracingProducerInterceptor
-...
-# For consumers
-mp.messaging.incoming.prices.interceptor.classes=io.opentracing.contrib.kafka.TracingConsumerInterceptor
-
-
-
-
-
-BouncyCastle -
-
-

Quarkus supports BouncyCastle, you only need to add the BouncyCastle dependency and configure the security provider:

-
-
-
-
quarkus.security.security-providers=BC
-quarkus.security.security-providers=BCJSSE
-quarkus.security.security-providers=BCFIPS
-quarkus.security.security-providers=BCFIPSJSSE
-
-
-
-
-
-Knative Properties -
-
-

Knative Properties

-
-
-

Most of the Kubernetes properties are valid in Knative output by just changing the kubernetes prefix to knative prefix (ie quarkus.kubernetes.readiness-probe.period-seconds to quarkus.knative.readiness-probe.period-seconds).

-
-
-

There are also specific properties for Knative:

-
-
-
-
quarkus.kubernetes.deployment-target=knative
-quarkus.knative.revision-name=my-revision
-quarkus.knative.traffic.my-revision.percentage=80
-
-
-
-
-
-Swagger UI Properties -
-
-

Possible Swagger UI options with quarkus.swagger-ui prefix:

-
-
-
-
urls
-
-

The urls that will be included as options. (ie quarkus.swagger-ui.urls.petstore=https://petstore.swagger.io/v2/swagger.json)

-
-
urls-primary-name
-
-

If urls option is used, this will be the name of the default selection.

-
-
title
-
-

The html title for the page.

-
-
theme
-
-

Swagger UI theme to be used.

-
-
footer
-
-

A footer for the html page. Nothing by default.

-
-
deep-linking
-
-

Enables deep linking for tags and operations.

-
-
display-operation-id
-
-

Controls the display of operationId in operations list.

-
-
default-models-expand-depth
-
-

The default expansion depth for models.

-
-
default-model-expand-depth
-
-

The default expansion depth for the model on the model-example section.

-
-
default-model-rendering
-
-

Controls how the model is shown when the API is first rendered.

-
-
display-request-duration
-
-

Controls the display of the request duration (in milliseconds) for "Try it out" requests.

-
-
doc-expansion
-
-

Controls the default expansion setting for the operations and tags.

-
-
filter
-
-

Enables filtering.

-
-
max-displayed-tags
-
-

Limits the number of tagged operations displayed to at most this many.

-
-
operations-sorter
-
-

Apply a sort to the operation list of each API. (alpha, method, function)

-
-
show-extensions
-
-

Controls the display of vendor extension.

-
-
show-common-extensions
-
-

Controls the display of extensions.

-
-
tag-sorter
-
-

Apply a sort to the tag list of each API.

-
-
on-complete
-
-

Provides a mechanism to be notified when Swagger UI has finished rendering a newly provided definition.

-
-
syntax-highlight
-
-

Set to false to deactivate syntax highlighting of payloads and cURL command.

-
-
oauth2-redirect-url
-
-

OAuth redirect URL.

-
-
request-interceptor
-
-

Function to intercept remote definition, "Try it out", and OAuth 2.0 requests.

-
-
request-curl-options
-
-

Array of command line options available to the curl command.

-
-
response-interceptor
-
-

Function to intercept remote definition, "Try it out", and OAuth 2.0 responses.

-
-
show-mutated-request
-
-

Uses the mutated request returned from a requestInterceptor to produce the curl command in the UI.

-
-
supported-submit-methods
-
-

List of HTTP methods that have the "Try it out" feature enabled.

-
-
validator-url
-
-

Swagger UI attempts to validate specs against swagger.io’s online validator.

-
-
with-credentials
-
-

Enables passing credentials, as defined in the Fetch standard, in CORS requests that are sent by the browser.

-
-
model-property-macro
-
-

Function to set default values to each property in model.

-
-
parameter-macro
-
-

Function to set default value to parameters.

-
-
persist-authorization
-
-

It persists authorization data and it would not be lost on browser close/refresh.

-
-
layout
-
-

The name of a component available via the plugin system to use as the top-level layout for Swagger UI.

-
-
plugins
-
-

A list of plugin functions to use in Swagger UI.

-
-
presets
-
-

A list of presets to use in Swagger UI.

-
-
-
-
-
-
-Default to JSON -
-
- - - - - -
- - -Default media type in Quarkus RestEasy is JSON. -
-
-
-
-
-Amazon IAM -
-
-
-
mvn quarkus:add-extension
-    -Dextensions="quarkus-amazon-iam"
-
-
-
-

You need to set a HTTP client either URL Connection:

-
-
-
-
<dependency>
-    <groupId>software.amazon.awssdk</groupId>
-    <artifactId>url-connection-client</artifactId>
-</dependency>
-
-
-
-

or Apache HTTP:

-
-
-
-
<dependency>
-    <groupId>software.amazon.awssdk</groupId>
-    <artifactId>apache-client</artifactId>
-</dependency>
-
-
-
-

And you need to add the asynchronous Netty client:

-
-
-
-
<dependency>
-    <groupId>software.amazon.awssdk</groupId>
-    <artifactId>netty-nio-client</artifactId>
-</dependency>
-
-
-
-
-
@Inject
-IamClient client;
-
-@Inject
-IamAsyncClient async;
-
-
-
-
-
quarkus.iam.endpoint-override=${iam.url}
-quarkus.iam.aws.region=us-east-1
-quarkus.iam.aws.credentials.type=static
-quarkus.iam.aws.credentials.static-provider.access-key-id=test-key
-quarkus.iam.aws.credentials.static-provider.secret-access-key=test-secret
-
-
-
-

Configuration properties are the same as Amazon DynamoDB but changing the prefix from dynamodb to iam.

-
-
-
-
-
-

Version 1.9.0.Final

-
-JAXP -
-
-

To work with JAX-P you need to add a dependency:

-
-
-
-
./mvnw quarkus:add-extension
-  -Dextensions="jaxp"
-
-
-
-
-
final DocumentBuilder dBuilder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
-final Document doc = dBuilder.parse(in);
-return doc.getDocumentElement().getTextContent();
-
-
-
-
-
-Multiple Redis Clients -
-
-

Multiple Redis Clients

-
-
-
-
quarkus.redis.hosts = localhost:6379
-quarkus.redis.second.hosts = localhost:6379
-
-
-
-
-
@Inject
-RedisClient defaultRedisClient;
-
-@Inject
-@RedisClientName("second")
-RedisClient redisClient2;
-
-
-
-
-
-TestTransaction -
-
-

If you want any changes made to be rolled back at the end ofthe test you can use the io.quarkus.test.TestTransaction annotation.

-
-
-
-
-Instantiate client programmatically -
-
-
-
MovieReviewService reviewSvc = RestClientBuilder.newBuilder()
-            .baseUri(apiUri)
-            .build(WorldClockService.class);
-
-
-
-
-
-Message Bundling and Localization -
-
-
-
@io.quarkus.qute.i18n.MessageBundle
-public interface AppMessages {
-    @io.quarkus.qute.i18n.Message("Hello {name}!")
-    String hello_name(String name);
-}
-
-
-
-

There are 3 methods to inject the message:

-
-
-
-
MessageBundles.get(AppMessages.class).hello_name("Lucie");
-
-
-
-

or

-
-
-
-
@Inject AppMessages app;
-
-app.hello_name("Lucie");
-
-
-
-

or

-
-
-
-
<p>{msg:hello_name('Lucie')}</p>
-
-
-
-

Localization

-
-
-

There are two ways to set localized message:

-
-
-
-
@io.quarkus.qute.i18n.Localized("de")
-public interface GermanAppMessages {
-
-    @Override
-    @io.quarkus.qute.i18n.Message("Hallo {name}!")
-    String hello_name(String name);
-}
-
-
-
-

or

-
-
-
msg_de.properties
-
-
hello_name=Hallo {name}!
-
-
-
-
-
-Testing Callback -
-
-

You can enrich all your @QuarkusTest classes by implementing the following callback interfaces:

-
-
-
    -
  • -

    io.quarkus.test.junit.callback.QuarkusTestBeforeClassCallback

    -
  • -
  • -

    io.quarkus.test.junit.callback.QuarkusTestAfterConstructCallback

    -
  • -
  • -

    io.quarkus.test.junit.callback.QuarkusTestBeforeEachCallback

    -
  • -
  • -

    io.quarkus.test.junit.callback.QuarkusTestAfterEachCallback

    -
  • -
-
-
-
-
public class SimpleAnnotationCheckerBeforeClassCallback implements QuarkusTestBeforeClassCallback {
-   @Override
-    public void beforeClass(Class<?> testClass) {
-    }
-}
-
-
-
-

And needs to be registered as Java SPI:

-
-
-
META-INF/services/io.quarkus.test.junit.callback.QuarkusTestBeforeClassCallback
-
-
io.quarkus.it.main.SimpleAnnotationCheckerBeforeClassCallback
-
-
-
-
-
-
-

Version 1.8.0.Final

-
-Disable cache extension -
-
-

You can disable the caching system by setting quarkus.cache.enabled property to false.

-
-
-
-
-Include Qute templates -
-
-

Including templates passing parameters:

-
-
-
-
<html>
-<head>
-<meta charset="UTF-8">
-<title>Simple Include</title>
-</head>
-<body>
-  {#include foo limit=10 /}
-</body>
-</html>
-
-
-
-
-
-Common Reactive DataSource Configuration -
-
-

Common Reeactive DataSource Client configuration properties prefixed with quarkus.datasource:

-
-
-
-
reactive.cache-prepared-statements
-
-

Prepared statements should be cached on the client side. (default: false)

-
-
reactive.url
-
-

The datasource URL.

-
-
reactive.max-size
-
-

The datasource pool maximum size.

-
-
reactive.trust-all
-
-

All server certificates should be trusted. (default: false)

-
-
reactive.trust-certificate-pem
-
-

Trust configuration in the PEM format.

-
-
reactive.trust-certificate-jks
-
-

Trust configuration in the JKS format.

-
-
reactive.trust-certificate-pfx
-
-

Trust configuration in the PFX format.

-
-
reactive.key-certificate-pem
-
-

Key/cert configuration in the PEM format.

-
-
reactive.key-certificate-jks
-
-

Key/cert configuration in the JKS format.

-
-
reactive.key-certificate-pfx
-
-

Key/cert configuration in the PFX format.

-
-
reactive.thread-local
-
-

Use one connection pool per thread.

-
-
reactive.reconnect-attempts
-
-

The number of reconnection attempts when a pooled connection cannot be established on first try. (default: 0)

-
-
reactive.reconnect-interval
-
-

The interval between reconnection attempts when a pooled connection cannot be established on first try. (default: PT1S)

-
-
reactive.idle-timeout
-
-

The maximum time without data written to or read from a connection before it is removed from the pool.

-
-
-
-
-
-
-Export OpenAPI schema -
-
-

You can store generated OpenAPI schema if quarkus.swagger-ui.store-schema-directory is set.

-
-
-
-
-Quartz Configuration values -
-
-

Quartz can be configured usinf the following properties with quarkus.quartz prefix:

-
-
-
-
clustered
-
-

Enable cluster mode or not.

-
-
store-type
-
-

The type of store to use. Possible values: ram, db (default: ram)

-
-
datasource
-
-

The name of the datasource to use.

-
-
table-prefix
-
-

The prefix for quartz job store tables. (default: QRTZ_)

-
-
trigger-listeners.<name>.class
-
-

Class name for the trigger.

-
-
trigger-listeners.<name>.property-name
-
-

The properties passed to the class.

-
-
job-listeners.<name>.class
-
-

Class name for the job.

-
-
job-listeners.<name>.property-name
-
-

The properties passed to the class.

-
-
plugins.<name>.class
-
-

Class name for the plugin.

-
-
plugins.<name>.property-name
-
-

The properties passed to the class.

-
-
instance-name
-
-

The name of the Quartz instance. (default: QuarkusQuartzScheduler)

-
-
thread-count
-
-

The size of scheduler thread pool. (default: 25)

-
-
thread-priority
-
-

Thread priority of worker threads in the pool. (default: 5)

-
-
force-start
-
-

The scheduler will be started even if no scheduled business methods are found.

-
-
start-mode
-
-

Scheduler can be started in different modes: normal, forced or halted. (default: normal)

-
-
-
-
-
-
-JBang -
-
-

Creating an initial script:

-
-
-
-
jbang scripting/quarkusapp.java
-
-
-
-

Adding Quarkus dependencies in script:

-
-
-
-
//DEPS io.quarkus:quarkus-resteasy:{quarkus-version}
-
-
-
-

Put some Quarkus CLI code:

-
-
-
-
@Path("/hello")
-@ApplicationScoped
-public class quarkusapp {
-    @GET
-    public String sayHello() {
-        return "hello";
-    }
-    public static void main(String[] args) {
-        Quarkus.run(args);
-    }
-}
-
-
-
-

To run the script:

-
-
-
-
jbang quarkusapp.java
-
-
-
-
-
-Micrometer extension -
-
-

There is a tight integration with Micrometer in the form of an extension:

-
-
-
-
./mvnw quarkus:add-extension
-  -Dextensions="micrometer"
-
-
-
-

Add a micrometer dependency for the registry of your choosing:

-
-
-
-
<dependency>
-    <groupId>io.micrometer</groupId>
-    <artifactId>micrometer-registry-prometheus</artifactId>
-</dependency>
-
-
-
-

You can configure Micrometer. -Prefix is quarkus.micrometer:

-
-
-
-
enabled
-
-

Micrometer metrics support. (default: true)

-
-
registry-enabled-default
-
-

Micrometer MeterRegistry discovery. (default: true)

-
-
binder-enabled-default
-
-

Micrometer MeterBinder discovery. (default: true)

-
-
binder.vertx.enabled
-
-

Vert.x metrics support.

-
-
binder.mp-metrics.enabled
-
-

Microprofile Metrics support.

-
-
binder.jvm
-
-

Micrometer JVM metrics support. (default: true)

-
-
binder.system
-
-

Micrometer System metrics support. (default: true)

-
-
export.datadog.enabled
-
-

Support for export to Datadog Support for Datadog.

-
-
export.jmx.enabled
-
-

Support for export to JMX Support for JMX.

-
-
export.prometheus.enabled
-
-

Support for export to Prometheus.

-
-
export.prometheus.path
-
-

The path for the prometheus metrics endpoint (produces text/plain). (default: /q/metrics)

-
-
export.azuremonitor.enabled
-
-

Support for export to Azure Monitor.

-
-
export.azuremonitor.instrumentation-key
-
-

The path for the azure monitor instrumentationKey.

-
-
export.statsd.enabled
-
-

Support for export to StatsD.

-
-
export.stackdriver.enabled
-
-

Micrometer metrics support. (default: true)

-
-
export.signalfx.enabled
-
-

Micrometer metrics support. (default: true)

-
-
export.signalfx.uri
-
-

Signalfx URI.

-
-
export.signalfx.access-token
-
-

Access Token.

-
-
binder.vertx.match-patterns
-
-

Comma-separated case-sensitive list of regular expressions defining Paths that should be matched and used as tags

-
-
binder.vertx.ignore-patterns
-
-

Comma-separated case-sensitive list of regular expressions defining Paths that should be ignored / not measured.

-
-
export.datadog
-
-

Datadog MeterRegistry configuration in Map<String, String> format.

-
-
export.jmx
-
-

JMX registry configuration properties in Map<String, String> format.

-
-
export.prometheus
-
-

Prometheus registry configuration properties in Map<String, String> format.

-
-
export.stackdriver
-
-

Stackdriver registry configuration properties in Map<String, String> format.

-
-
-
-
-
+

In this page you can either read what has been added in each version of the cheat-sheet individually in [whatsnew] section, see the full cheat-sheet as HTML Quarkus Cheat-Sheet format or download the full cheat-sheet as PDF.

@@ -2034,21 +465,11 @@

Quarkus Cheat-Sheet

-

Download the Cheat-Sheet as PDF.

+

Download the Cheat-Sheet as PDF.

Table of Contents
-

Cheat-sheet tested with Quarkus 1.13.0.Final.

+

Cheat-sheet tested with Quarkus 2.7.0.Final.

@@ -2187,7 +612,7 @@

+
+

Command Mode applications can be tested using the @QuarkusMainTest and @QuarkusMainIntegrationTest annotations.

+
+
+
+
import io.quarkus.test.junit.main.Launch;
+import io.quarkus.test.junit.main.LaunchResult;
+import io.quarkus.test.junit.main.QuarkusMainLauncher;
+import io.quarkus.test.junit.main.QuarkusMainTest;
+
+@QuarkusMainTest
+public class HelloTest {
+    @Test
+    @Launch("World")
+    public void testLaunchCommand(LaunchResult result) {
+        Assertions.assertEquals("Hello World", result.getOutput());
+    }
+    @Test
+    @Launch(value = {}, exitCode = 1)
+    public void testLaunchCommandFailed() {
+    }
+    @Test
+    public void testManualLaunch(QuarkusMainLauncher launcher) {
+        LaunchResult result = launcher.launch("Everyone");
+        Assertions.assertEquals(0, result.exitCode());
+        Assertions.assertEquals("Hello Everyone", result.getOutput());
+    }
+}
+
+
+

Picocli

+

Dev Services

+
+

Quarkus supports the automatic provisioning of unconfigured services in development and test mode.

+
+
+

General configuration properties:

+
+
+
+
quarkus.devservices.enabled
+
+

If you want to disable all Dev Services. (default: true)

+
+
quarkus.devservices.timeout
+
+

Startup timeout. (default: 60S)

+
+
+
+
+

Set DOCKER_HOST env var to a remote Docker Host to use it instead the local one.

+
+
+

Dev UI

Quarkus adds a Dev UI console to expose extension features.

@@ -2552,6 +1034,26 @@

+

Continuous Testing

+
+

Quarkus supports continuous testing, where tests run immediately after code changes have been saved. This allows you to get instant feedback on your code changes. Quarkus detects which tests cover which code, and uses this information to only run the relevant tests when code is changed.

+
+
+

Start Quarkus in Dev Mode to run it.

+
+
+

Also, you can start continuous testing and not dev mode by running mvn quarkus:test.

+
+
+
+
quarkus.test.exclude-pattern
+
+

Tests that should be excluded with continuous testing default: .*\.IT[^.]+|.*IT|.*ITCase

+
+
+
+

+

Adding Configuration Parameters

+
+
+
@UnlessBuildProfile("test")
+@ConfigProperties
+public class ServiceConfiguration {
+    public String user;
+    public String password;
+}
+
+
+

Also you can use an interface approach:

+

@LookupIfProperty indicates that a bean should only be obtained if a runtime configuration property matches the provided value. +@LookupUnlessProperty, on the other hand, indicates that a bean should only be obtained if a runtime configuration property does not match the provided value.

+
+
+
+
@LookupIfProperty(name = "service.foo.enabled", stringValue = "true")
+@ApplicationScoped
+class ServiceFoo implements Service {
+
+    public String name() {
+       return "foo";
+    }
+}
+
+
+

Alternatives

+

Also spy is supported:

+
+

Quarkus also supports CDI Decorators:

+
+
+
+
@Priority(10)
+@Decorator
+public class LargeTxAccount implements Account {
+
+   @Inject
+   @Any
+   @Delegate
+   Account delegate;
+
+   @Inject
+   LogService logService;
+
+   void withdraw(BigDecimal amount) {
+      delegate.withdraw(amount);
+      if (amount.compareTo(1000) > 0) {
+         logService.logWithdrawal(delegate, amount);
+      }
+   }
+
+}
+
+
+

Test Coverage

+
+

Configuration properties prefixed with quarkus.hibernate-envers:

+
+
+
+
store-data-at-delete
+
+

Enable store_data_at_delete feature. (default: false)

+
+
audit-table-suffix
+
+

Defines a suffix for historical data table. (default: _AUD)

+
+
audit-table-prefix
+
+

Defines a prefix for historical data table. (default: ``)

+
+
revision-field-name
+
+

Revision field name. (default: REV)

+
+
revision-type-field-name
+
+

Revision type field name. (default: REVTYPE)

+
+
+

REST Data Panache

@@ -5653,6 +4283,39 @@

+
+

DevServices

+
+
+

When testing or running in dev mode Quarkus can even provide you with a zero config Infinispan out of the box.

+
+
+

Possible configuration values prefixed with quarkus.infinispan-client:

+
+
+
+
devservices.enabled
+
+

If devservices is enabled or not. (default: true)

+
+
devservices.port
+
+

Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly.

+
+
devservices.shared
+
+

Indicates if the Infinispan managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. (default: true)

+
+
devservices.service-name
+
+

The value of the quarkus-dev-service-infinispan label attached to the started container. (default: infinispan)

+
+
devservices.artifacts
+
+

List of the artifacts to automatically download and add to the Infinispan server libraries.

+
+
+

Redis

@@ -5705,6 +4368,39 @@

+

DevServices

+

+
+

When testing or running in dev mode Quarkus can even provide you with a zero config Redis out of the box.

+
+
+

Possible configuration values prefixed with quarkus.redis:

+
+
+
+
devservices.enabled
+
+

If devservices is enabled or not. (default: true)

+
+
devservices.image-name
+
+

The container image name to use instead of the default one.

+
+
devservices.port
+
+

Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly.

+
+
devservices.shared
+
+

Indicates if the Redis broker managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. (default: true)

+
+
devservices.service-name
+
+

The value of the quarkus-dev-service-redis label attached to the started container. (default: redis)

+
+
+
+

Multiple Redis Clients

+
+

Liquibase MongoDB

+
+
+
+
./mvnw quarkus:add-extension
+  -Dextensions="liquibase-mongodb"
+
+
+
+

Most of the configuration properties are valid but changing prefix to: quarkus.liquibase-mongodb

+
+

Amazon DynamoDB

@@ -7242,6 +5957,15 @@

+

DevServices

+

+
+

When testing or running in dev mode Quarkus can even provide you with a zero config Neo4j out of the box.

+
+

MongoDB Client

@@ -7273,6 +5997,24 @@

+

Testing

+
+
+

To start an embedded MongoDB database for your unit tests, Quarkus provides two QuarkusTestResourceLifecycleManager.

+
+
+

Add io.quarkus:quarkus-test-mongodb dependency.

+
+
+
+
// Single MongoDB instance
+@QuarkusTestResource(io.quarkus.test.mongodb.MongoTestResource.class)
+
+// ReplicaSet with two instances
+@QuarkusTestResource(io.quarkus.test.mongodb.MongoReplicaSetTestResource.class)
+
+
+

Multi MongoDB support

+
+

DevServices

+
+
+

When testing or running in dev mode Quarkus can even provide you with a zero config MongoDB database out of the box.

+
+
+
+
%prod.quarkus.mongodb.connection-string=mongodb://localhost:27018
+
+
+
+

Possible configuration values prefixed with quarkus.datasource:

+
+
+
+
devservices.enabled
+
+

If devservices is enabled or not. (default: true)

+
+
devservices.image-name
+
+

The container image name to use instead of the default one.

+
+
devservices.port
+
+

Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly.

+
+
devservices.properties
+
+

Generic properties that are added to the database connection URL.

+
+
+

Authentication mechanism properties.

+ +
+

read-concern

+
+
+

String

+
+

Configures the read concern. Possible values: local, majority, linearizable, snapshot, available

+ @@ -7773,6 +6558,12 @@

+

Transsactions

+
+
+

To use them with MongoDB with Panache you need to annotate the method that starts the transaction with the @Transactional annotation.

+
+

Testing

+

DevServices

+
+
+

When testing or running in dev mode Quarkus can even provide you with a zero config Kafka out of the box.

+
+
+

Possible configuration values prefixed with quarkus.kafka:

+
+
+
+
devservices.enabled
+
+

If devservices is enabled or not. (default: true)

+
+
devservices.image-name
+
+

The container image name to use instead of the default one. (default: docker.io/vectorized/redpanda:v21.5.5)

+
+
devservices.port
+
+

Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly.

+
+
devservices.shared
+
+

Indicates if the Kafka broker managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. (default: true)

+
+
devservices.service-name
+
+

The value of the quarkus-dev-service-kafka label attached to the started container. (default: kafka)

+
+
devservices.topic-partitions-timeout
+
+

Timeout for admin client calls used in topic creation. (default: 2S)

+
+
devservices.topic-partitions
+
+

The topic-partition pairs to create in the Dev Services Kafka broker. Example: quarkus.kafka.devservices.topic-partitions.test=2 will create a topic named test with 2 partitions

+
+
+
+
+

Apicurio Registry Avro

+
+
+

You can use Apicurio Registry Avro.

+
+
+
+
./mvnw quarkus:add-extension
+    -Dextensions="apicurio-registry-avro"
+
+
+
+

Place schemas at src/main/avro/ directory.

+
+
+
application.properties
+
+
mp.messaging.outgoing.movies.connector=smallrye-kafka
+mp.messaging.outgoing.movies.topic=movies
+
+# automatically register the schema with the registry, if not present
+mp.messaging.outgoing.movies.apicurio.registry.auto-register=true
+
+# URL of registry
+mp.messaging.connector.smallrye-kafka.schema.registry.url=http://localhost:8081
+
+
+
+

DevServices

+
+
+

When testing or running in dev mode Quarkus can even provide you with a zero config Apicurio Registry out of the box.

+
+
+

Possible configuration values prefixed with quarkus.apicurio-registry:

+
+
+
+
devservices.enabled
+
+

If devservices is enabled or not. (default: true)

+
+
devservices.image-name
+
+

The container image name to use instead of the default one. (default: docker.io/apicurio/apicurio-registry-mem:2.1.3.Final)

+
+
devservices.port
+
+

Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly.

+
+
devservices.shared
+
+

Indicates if the Apicurio managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. (default: true)

+
+
devservices.service-name
+
+

The value of the quarkus-dev-service-apicurio-registry label attached to the started container. (default: apicurio-registry)

+
+
+
+

AMQP

@@ -8517,6 +7410,158 @@

<

A complete list of supported properties for AMQP.

+

DevServices

+
+
+

When testing or running in dev mode Quarkus can even provide you with a zero config AMQP out of the box.

+
+
+

Possible configuration values prefixed with quarkus.amqp:

+
+
+
+
devservices.enabled
+
+

If devservices is enabled or not. (default: true)

+
+
devservices.image-name
+
+

The container image name to use instead of the default one. (default: quay.io/artemiscloud/activemq-artemis-broker:0.1.2)

+
+
devservices.port
+
+

Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly.

+
+
devservices.extra-args
+
+

The value of the AMQ_EXTRA_ARGS environment variable to pass to the container. (default: --no-autotune --mapped --no-fsync)

+
+
devservices.shared
+
+

Indicates if the AMQP broker managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. (default: true)

+
+
devservices.service-name
+
+

The value of the quarkus-dev-service-aqmp label attached to the started container. (default: amqp)

+
+
+
+
+

RabbitMQ

+
+
+

To integrate with RabbitMQ you need to add next extensions:

+
+
+
+
./mvnw quarkus:add-extension
+    -Dextensions="smallrye-reactive-messaging-rabbitmq"
+
+
+
+

Then @Outgoing, @Incoming or @Stream can be used.

+
+
+

The connector type is smallrye-rabbitmq.

+
+
+

RabbitMQ configuration schema: mp.messaging.[outgoing|incoming].{stream-name}.<property>=<value>.

+
+
+
+
mp.messaging.incoming.requests.connector=smallrye-rabbitmq
+mp.messaging.incoming.requests.queue.name=quote-requests
+mp.messaging.incoming.requests.exchange.name=quote-requests
+
+mp.messaging.outgoing.quotes.connector=smallrye-rabbitmq
+mp.messaging.outgoing.quotes.exchange.name=quotes
+
+
+
+

A complete list of supported properties for RabbitMQ.

+
+
+

DevServices

+
+
+

When testing or running in dev mode Quarkus can even provide you with a zero config RabbitMQ out of the box.

+
+
+

Possible configuration values prefixed with quarkus.rabbitmq:

+
+
+
+
devservices.enabled
+
+

If devservices is enabled or not. (default: true)

+
+
devservices.image-name
+
+

The container image name to use instead of the default one. (default: quay.io/kiegroup/kogito-data-index-ephemeral)

+
+
devservices.port
+
+

Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly.

+
+
devservices.shared
+
+

Indicates if the RabbitMQ managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. (default: true)

+
+
devservices.service-name
+
+

The value of the quarkus-dev-service-rabbitmq label attached to the started container. (default: rabbitmq)

+
+
devservices.exchanges.<exchanges>.type
+
+

Type of exchange: direct, topic, headers, fanout, etc. (default: direct)

+
+
devservices.exchanges.<exchanges>.auto-delete
+
+

Should the exchange be deleted when all queues are finished using it? (default: false)

+
+
devservices.exchanges.<exchanges>.durable
+
+

Should the exchange remain after restarts?

+
+
devservices.exchanges.<exchanges>.arguments
+
+

Extra arguments for the exchange definition.

+
+
devservices.queues.<queues>.auto-delete
+
+

Should the queue be deleted when all consumers are finished using it? (default: false)

+
+
devservices.queues.<queues>.durable
+
+

Should the queue remain after restarts? (default: false)

+
+
devservices.queues.<queues>.arguments
+
+

Extra arguments for the queue definition

+
+
devservices.bindings.<bindings>.source
+
+

Source exchange to bind to. Defaults to name of binding instance

+
+
devservices.bindings.<bindings>.routing-key
+
+

Routing key specification for the source exchange (default: #)

+
+
devservices.bindings.<bindings>.destination
+
+

Destination exchange or queue to bind to. Defaults to name of binding instance

+
+
devservices.bindings.<bindings>.destination-type
+
+

Destination type for binding: queue, exchange, etc. (default: queue)

+
+
devservices.bindings.<bindings>.arguments
+
+

Extra arguments for the binding definition

+
+
+
+

MQTT

@@ -8566,7 +7611,6 @@

< true

-

Kafka Streams

@@ -8663,6 +7707,11 @@

+
+

Testing

+
+
+

You can use @TestSecurity annotation tooin OIDC by registering the following dependency:

+
+
+
+
<dependency>
+    <groupId>io.quarkus</groupId>
+    <artifactId>quarkus-test-security-jwt</artifactId>
+    <scope>test</scope>
+</dependency>
+
+
+
+
+
@Test
+@TestSecurity(user = "userJwt", roles = "viewer")
+@JwtSecurity(claims = {
+    @Claim(key = "email", value = "user@gmail.com")
+})
+public void testJwtWithClaims() {}
+
+
+

Generate tokens

@@ -9410,52 +8484,117 @@

JW .header("custom-header", "custom-value"); .sign(createKey()); -Jwt.claims("/testJsonToken.json") - .encrypt(createKey()); +Jwt.claims("/testJsonToken.json") + .encrypt(createKey()); + +JwtEncryptionBuilder jwtEncryptionBuilder = Jwt.claims("/testJsonToken.json").jwe(); +jwtEncryptionBuilder + .keyEncryptionKeyId("some-key-id") + .keyEncryptionAlgorithm(KeyEncryptionAlgorithm.ECDH_ES_A256KW) + .header("custom-header", "custom-value"); + .encrypt(createKey()); + +Jwt.claims("/testJsonToken.json") + .innerSign(createKey()); + .encrypt(createKey()); +

+ + +
+

OpenId Connect

+
+

Quarkus can use OpenId Connect or OAuth 2.0 authorization servers such as Keycloak to protect resources using bearer token issued by Keycloak server.

+
+
+
+
mvn quarkus:add-extension
+    -Dextensions="using-openid-connect"
+
+
+
+

You can also protect resources with security annotations.

+
+
+
+
@GET
+@RolesAllowed("admin")
+
+
+
+

You can inject the folowing Oidc objects in a class:

+
+
+
+
@Inject
+io.quarkus.oidc.UserInfo userInfo;
+
+@Inject
+io.quarkus.oidc.OidcConfigurationMetadata configMetadata;
+
+
+
+

Configure application to Keycloak service in application.properties file.

+
+
+
+
quarkus.oidc.realm=quarkus
+quarkus.oidc.auth-server-url=http://localhost:8180/auth
+quarkus.oidc.resource=backend-service
+quarkus.oidc.bearer-only=true
+quarkus.oidc.credentials.secret=secret
+
+
+
+

quarkus-oidc-client can be configured as follows to support MTLS:

+
+
+
+
quarkus.oidc.tls.verification=certificate-validation
+
+quarkus.oidc.client.tls.key-store-file=client-keystore.jks
+quarkus.oidc.client.tls.key-store-password=${key-store-password}
 
-JwtEncryptionBuilder jwtEncryptionBuilder = Jwt.claims("/testJsonToken.json").jwe();
-jwtEncryptionBuilder
-     .keyEncryptionKeyId("some-key-id")
-      .keyEncryptionAlgorithm(KeyEncryptionAlgorithm.ECDH_ES_A256KW)
-     .header("custom-header", "custom-value");
-     .encrypt(createKey());
+quarkus.oidc.client.tls.key-store-alias=keyAlias
+quarkus.oidc.client.tls.key-store-alias-password=keyAliasPassword
 
-Jwt.claims("/testJsonToken.json")
-  .innerSign(createKey());
-  .encrypt(createKey());
+quarkus.oidc.client.tls.trust-store-file=client-truststore.jks +quarkus.oidc.client.tls.trust-store-password=${trust-store-password} + +quarkus.oidc.client.tls.trust-store-alias=certAlias
+
+

There is also support for the public OIDC providers:

-
-

OpenId Connect

-

Quarkus can use OpenId Connect or OAuth 2.0 authorization servers such as Keycloak to protect resources using bearer token issued by Keycloak server.

+

GitHub

-
mvn quarkus:add-extension
-    -Dextensions="using-openid-connect"
+
quarkus.oidc.provider=github
+quarkus.oidc.client-id=github_app_clientid
+quarkus.oidc.credentials.secret=github_app_clientsecret
-

You can also protect resources with security annotations.

+

Apple

-
@GET
-@RolesAllowed("admin")
+
quarkus.oidc.provider=apple
+quarkus.oidc.client-id=${apple.client-id}
+quarkus.oidc.credentials.jwt.token-key-id=${apple.key-id}
-

Configure application to Keycloak service in application.properties file.

+

Google

-
quarkus.oidc.realm=quarkus
-quarkus.oidc.auth-server-url=http://localhost:8180/auth
-quarkus.oidc.resource=backend-service
-quarkus.oidc.bearer-only=true
-quarkus.oidc.credentials.secret=secret
+
quarkus.oidc.provider=google
+quarkus.oidc.client-id={GOOGLE_CLIENT_ID}
+quarkus.oidc.credentials.secret={GOOGLE_CLIENT_SECRET}
+quarkus.oidc.token.issuer=https://accounts.google.com
+

Testing

+
+
+

You can use @TestSecurity annotation tooin OIDC by registering the following dependency:

+
+
+
+
<dependency>
+    <groupId>io.quarkus</groupId>
+    <artifactId>quarkus-test-security-oidc</artifactId>
+    <scope>test</scope>
+</dependency>
+
+
+
+
+
@Test
+@TestSecurity(user = "userOidc", roles = "viewer")
+@OidcSecurity(claims = {
+        @Claim(key = "email", value = "user@gmail.com")
+}, userinfo = {
+        @UserInfo(key = "sub", value = "subject")
+}, config = {
+        @ConfigMetadata(key = "issuer", value = "issuer")
+})
+public void testOidcWithClaimsUserInfoAndMetadata() {}
+
+
+
+

DevServices

+
+
+

When testing or running in dev mode Quarkus can even provide you with a zero config Keycloak out of the box.

+
+
+

Possible configuration values prefixed with quarkus.keycloak:

+
+
+
+
devservices.enabled
+
+

If devservices is enabled or not. (default: true)

+
+
devservices.image-name
+
+

The container image name to use instead of the default one. Keycloak-X can be used (quay.io/keycloak/keycloak-x:15.0.2) (default: quay.io/keycloak/keycloak:15.0.2)

+
+
devservices.keycloak-x-image
+
+

Set quarkus.devservices.keycloak.keycloak-x-image to override this check which may be necessary if you build custom Keycloak-X or Keycloak images. You do not need to set this property if the default check works.

+
+
devservices.port
+
+

Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly.

+
+
devservices.shared
+
+

Indicates if the Keycloak broker managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. (default: true)

+
+
devservices.service-name
+
+

The value of the quarkus-dev-service-keycloak label attached to the started container. (default: kafka)

+
+
devservices.realm-path
+
+

The class or file system path to a Keycloak realm file which will be used to initialize Keycloak

+
+
devservices.java-opts
+
+

The JAVA_OPTS passed to the keycloak JVM

+
+
devservices.realm-name
+
+

The Keycloak realm name

+
+
devservices.create-realm
+
+

Indicates if the Keycloak realm has to be created when the realm file pointed to by the 'realm-path' property does not exist

+
+
devservices.users
+
+

The Keycloak users map containing the user name and password pairs

+
+
devservices.roles
+
+

The Keycloak user roles

+
+
+
+

Multi-tenancy

+
+

You can inject io.quarkus.oidc.client.Tokens, io.quarkus.oidc.OidcSession, and io.quarkus.oidc.client.OidcClient to interact with OIDC.

+
+
+
+
@Inject
+@io.quarkus.oidc.client.NamedOidcClient("client2")
+OidcClient client;
+
+@Inject
+@io.quarkus.oidc.client.NamedOidcClient("client1")
+Tokens tokens1;
+
+@Inject
+OidcSession oidcSession;
+
+

OAuth2

@@ -9928,11 +9178,6 @@

-
-
principal-query.bcrypt-password-mapper.salt-index

The index column containing the Bcrypt salt. (default: 0)

@@ -10332,6 +9577,19 @@

+

PKI

+

+
+
+
@Inject
+public VaultPKISecretEngine pkiSecretEngine;
+
+GenerateCertificateOptions options = new GenerateCertificateOptions();
+    SignedCertificate signed = pkiSecretEngine.signRequest("example-dot-com", csr, options);
+return signed.certificate.getData();
+
+
+

Vault configuration properties. Prefix quarkus.vault is skipped.

@@ -10447,6 +9705,15 @@

+

DevServices

+ +
+

When testing or running in dev mode Quarkus can even provide you with a zero config Vault out of the box.

+
+

Amazon KMS

@@ -10601,13 +9868,17 @@

<

+
http.access-log.exclude-pattern
+
+

A regular expression that can be used to exclude some paths from logging

+
cors

Enable CORS. (default: false)

cors.origins
-

CSV of origins allowed. (dedault: Any request valid.)

+

CSV of origins allowed. Regular expressions are also allowed (dedault: Any request valid.)

cors.methods
@@ -10643,40 +9914,52 @@

<

test-ssl-port
-

The HTTPS port used to run tests. (default 8444)

+

The HTTPS port used to run tests. (default: 8444)

+
+
insecure-requests
+
+

If insecure requests are allowed. Possible values: enabled, redirect, disable. (default: enabled)

+
+
http2
+
+

Enables HTTP/2. (default: true)

-
proxy-address-forwarding
+
proxy.proxy-address-forwarding

The address, scheme etc will be set from headers forwarded by the proxy server.

-
allow-forwarded
+
proxy.allow-forwarded

Proxy address forwarding is enabled then the standard Forwarded header will be used, rather than the more common but not standard X-Forwarded-For.

-
insecure-requests
+
proxy.enable-forwarded-host
-

If insecure requests are allowed. Possible values: enabled, redirect, disable. (default: enabled)

+

Enable override the received request’s host through a forwarded host header

-
http2
+
proxy.forwarded-host-header
-

Enables HTTP/2. (default: true)

+

Configure the forwarded host header to be used if override enabled

ssl.port

The HTTPS port. (default: 8443)

-
ssl.certificate.file
+
ssl.certificate.files
-

The file path to a service certificate or certificate chain in PEM format. Relative to src/main/resources.

+

The files path to a service certificate or certificate chain in PEM format. Relative to src/main/resources.

-
ssl.certificate.key-file
+
ssl.certificate.key-files
-

The file path to the corresponding certificate private key in PEM format. Relative to src/main/resources.

+

The files path to the corresponding certificate private key in PEM format. Relative to src/main/resources.

ssl.certificate.key-store-file

The key store contains the certificate information. Relative to src/main/resources.

+
ssl.certificate.key-store-key-alias
+
+

An optional parameter to select a specific key in the key store.

+
ssl.certificate.key-store-file-type

The key store type. It is automatically detected based on the file name or can be set manually. Supported values are: JKS, JCEKS, P12, PKCS12 or PFX.

@@ -10685,14 +9968,14 @@

<

The password to open the key store file.

-

-
-
-

ssl.certificate.trust-store-file -The trust store location which contains the certificate information of the certificates to trust. Relative to src/main/resources.

-
-
-
+
ssl.certificate.trust-store-file
+
+

The trust store location which contains the certificate information of the certificates to trust. Relative to src/main/resources.

+
+
ssl.certificate.trust-store-cert-alias
+
+

An optional parameter to trust only one specific certificate in the trust store

+
ssl.certificate.trust-store-file-type

The trust store type. It is automatically detected based on the file name or can be set manually.

@@ -10709,6 +9992,10 @@

<

The list of protocols to explicitly enable. (default: TLSv1.3 and TLSv1.2).

+
ssl.sni
+
+

Enables Server Name Indication (SNI), an TLS extension allowing the server to use multiple certificates. (default: false)

+
ssl.client-auth

Configures the engine to require/request client authentication. Possible values are: none, request and required. (default: none).

@@ -11193,12 +10480,76 @@

schema-available +
+

Make the schema available over HTTP. (default: true)

+
metrics.enabled

Enable metrics. (default: false)

+
+

GraphQL Clients

+
+
+
+
./mvnw quarkus:add-extension
+  -Dextensions="graphql-client"
+
+
+
+
+
quarkus.smallrye-graphql-client.star-wars.url=https://swapi-graphql.netlify.app/.netlify/functions/index
+
+
+
+

Typesafe client

+
+
+
+
@GraphQLClientApi(configKey = "star-wars")
+public interface StarWarsClientApi {
+
+    FilmConnection allFilms();
+
+}
+
+@Inject
+StarWarsClientApi typesafeClient;
+
+
+
+

allFilms is also the name of the query. +You can override the value using @Query(value="allStarWarsFilms")

+
+
+

Dynamic client

+
+
+
+
@Inject
+@GraphQLClient("star-wars")
+DynamicGraphQLClient dynamicClient;
+
+Document query = document(
+        operation(
+            field("allFilms",
+                field("films",
+                    field("title"),
+                    field("planetConnection",
+                        field("planets",
+                            field("name")
+                        )
+                    )
+                )
+            )
+        )
+    );
+Response response = dynamicClient.executeSync(query)
+
+
+
+

Smallrye Stork

+
+

Stork implements client load-balancing strategies supporting Kubernetes, and Consul.

+
+
+

Consul

+
+
+

Add following dependencies:

+
+
+
+
<dependency>
+  <groupId>io.smallrye.stork</groupId>
+  <artifactId>stork-service-discovery-consul</artifactId>
+</dependency>
+<dependency>
+  <groupId>io.smallrye.reactive</groupId>
+  <artifactId>smallrye-mutiny-vertx-consul-client</artifactId>
+</dependency>
+
+
+
+

Register service instances to Consul:

+
+
+
+
@ApplicationScoped
+public class Registration {
+
+    @ConfigProperty(name = "consul.host") String host;
+    @ConfigProperty(name = "consul.port") int port;
+
+    public void init(@Observes StartupEvent ev, Vertx vertx) {
+        ConsulClient client = ConsulClient.create(vertx,
+                                new ConsulClientOptions().setHost(host).setPort(port));
+
+        client.registerServiceAndAwait(
+                new ServiceOptions().setPort(8080)
+                    .setAddress("host1").setName("my-service").setId("blue"));
+        client.registerServiceAndAwait(
+                new ServiceOptions().setPort(8080)
+                    .setAddress("host2").setName("my-service").setId("red"));
+
+    }
+}
+
+
+
+

Configuration:

+
+
+
+
consul.host=localhost
+consul.port=8500
+
+stork.my-service.service-discovery=consul
+stork.my-service.service-discovery.consul-host=localhost
+stork.my-service.service-discovery.consul-port=8500
+stork.my-service.load-balancer=round-robin
+
+
+
+

Kubernetes

+
+
+

Add following dependencies:

+
+
+
+
<dependency>
+  <groupId>io.smallrye.reactive</groupId>
+  <artifactId>stork-service-discovery-kubernetes</artifactId>
+</dependency>
+
+
+
+
+
stork.my-service.service-discovery=kubernetes
+stork.my-service.service-discovery.k8s-namespace=my-namespace
+stork.my-service.load-balancer=round-robin
-

Some configuration example to set the host and the SSL parameters:

+

Using Stork at client

-
quarkus.grpc.clients.hello.host=localhost
-quarkus.grpc.clients.hello.plain-text=false
-quarkus.grpc.clients.hello.ssl.certificate=src/main/resources/tls/client.pem
-quarkus.grpc.clients.hello.ssl.key=src/main/resources/tls/client.key
-quarkus.grpc.clients.hello.ssl.trust-store=src/main/resources/tls/ca.pem
+
@RegisterRestClient(baseUri = "stork://my-service")
+public interface MyService {
+
+    @GET
+    @Produces(MediaType.TEXT_PLAIN)
+    String get();
+}
@@ -11484,6 +10962,21 @@

+

From smallrye project Fibonacci and Exponential Backoff retries annotations are provided:

+
+
+
+
public class TwoBackoffsOnMethodService {
+    @Retry
+    @io.smallrye.faulttolerance.api.ExponentialBackoff
+    @io.smallrye.faulttolerance.api.FibonacciBackoff
+    public void hello() {
+        throw new IllegalArgumentException();
+    }
+}
+
+
+

Fault tolerance annotations:

@@ -11769,7 +11262,10 @@

-
quarkus.kafka-streams.health.enabled=false
+
quarkus.datasource.myotherdatasource.health-exclude=true
+quarkus.datasource.health.enabled=true
+
+quarkus.kafka-streams.health.enabled=false
 quarkus.mongodb.health.enabled=false
 quarkus.neo4j.health.enabled=false
@@ -11806,6 +11302,23 @@

+

MicroProfile Health currently doesn’t support returning reactive types, but SmallRye Health does. +Implement the io.smallrye.health.api.AsyncHealthCheck interface instead of the org.eclipse.microprofile.health.HealthCheck.

+ +
+
+
@Liveness
+@ApplicationScoped
+public class LivenessAsync implements AsyncHealthCheck {
+    @Override
+    public Uni<HealthCheckResponse> call() {
+        return Uni.createFrom().item(HealthCheckResponse.up("liveness-reactive"))
+                .onItem().delayIt().by(Duration.ofMillis(10));
+    }
+}
+
+
+

Metrics

+
+
+
./mvnw quarkus:add-extension
+    -Dextensions="opentelemetry-otlp-exporter"
+
+
+
+

Possible configuration:

+
+
+
+
quarkus.application.name=myservice
+quarkus.opentelemetry.enabled=true
+quarkus.opentelemetry.tracer.exporter.otlp.endpoint=http://localhost:4317
+
+quarkus.opentelemetry.tracer.exporter.otlp.headers=Authorization=Bearer my_secret
+
+
+
+

The OpenTelemetry extension enables the W3C Trace Context and the W3C Baggage propagators, you can however choose any of the supported OpenTelemetry propagators.

+
+
+

The b3, b3multi, jaeger and ottrace propagators:

+
+
+
+
<dependency>
+    <groupId>io.opentelemetry</groupId>
+    <artifactId>opentelemetry-extension-trace-propagators</artifactId>
+</dependency>
+
+
+
+

The xray propagator:

+
+
+
+
<dependency>
+    <groupId>io.opentelemetry</groupId>
+    <artifactId>opentelemetry-extension-aws</artifactId>
+</dependency>
+
+
-

Quarkus integrates with the OpenTelemetry project. -For exporting traces to a Jaeger collector, use the quarkus-opentelemetry-exporter-jaeger extension.

+

You can configure OpenTelemetry. +Prefix is quarkus.opentelemetry:

+
+
+
+
enabled
+
+

OpenTelemetry support (default: true)

+
+
propagators
+
+

Comma separated list of OpenTelemetry propagators which must be supported. Possible values b3, b3multi, baggage, jaeger, ottrace, tracecontext, xray (default: traceContext,baggage).

+
+
tracer.enabled
+
+

Support for tracing with OpenTelemetry.

+
+
tracer.resource-attributes
+
+

A comma separated list of name=value resource attributes that represents the entity producing telemetry

+
+
tracer.sampler
+
+

The sampler to use for tracing. Possible values off, on, ratio. (Default: on)

+
+
tracer.sampler.ratio
+
+

Ratio to sample

+
+
tracer.sampler.parent-based
+
+

If the sampler to use for tracing is parent based (default: true)

+
+
tracer.suppress-non-application-uris
+
+

Suppress non-application uris from trace collection. (default: true)

+
+
tracer.exporter.otlp.enabled
+
+

OTLP SpanExporter support (default: true)

+
+
tracer.exporter.otlp.endpoint
+
+

The OTLP endpoint to connect to

+
+
tracer.exporter.otlp.headers
+
+

Key-value pairs to be used as headers associated with gRPC requests

+
+
tracer.exporter.otlp.export-timeout
+
+

The maximum amount of time to wait for the collector to process exported spans before an exception is thrown. (default: 10S)

+
+
tracer.exporter.otlp.compression
+
+

Compression method to be used by exporter to compress the payload

+
+
+

To produce a native executable with native excutable use -Dquarkus.native.additional-build-args=-J—​enable-preview.

+
+

SSL

+
+
+
./mvnw quarkus:add-extensions
+    -Dextensions="quarkus-container-image-buildpack"
+
+
+
+

Prefix is quarkus.buildpack:

+
+
+
+
jvm-builder-image
+
+

The buildpacks builder image to use when building the project in jvm mode.

+
+
native-builder-image
+
+

The buildpacks builder image to use when building the project in native mode.

+
+
builder-env
+
+

Environment key/values to pass to buildpacks.

+
+
run-image
+
+

The buildpacks run image to use when building the project.

+
+
pull-timeout-seconds
+
+

Max pull timeout for builder/run images, in seconds (default: 300)

+
+
docker-host
+
+

DOCKER_HOST value to use.

+
+
log-level
+
+

Log level to use. (default info)

+
+
base-registry-username
+
+

The username to use to authenticate with the registry used to pull the base image.

+
+
base-registry-password
+
+

The password to use to authenticate with the registry used to pull the base image.

+
+
+
+

S2I

-

Datasource configuration part is absent as it is aut-discovered by Quarkus.

+

Datasource configuration part is absent as it is auto-discovered by Quarkus.

+

If you only want the client you can include quarkus-websockets-client.

+
+

And web sockets classes can be used:

@@ -13655,54 +13336,110 @@

-
path
+
path

The path at which to register the OpenAPI Servlet. (default: openapi)

-
store-schema-directory
+
store-schema-directory

The generated OpenAPI schema documents will be stored here on build.

-
security-scheme
+
always-run-filter
+
+

Do not run the filter only at startup, but every time the document is requested (dynamic). (default: false)

+
+
ignore-static-document
+
+

Do not include the provided static openapi document. (default: false)

+
+
additional-docs-directory
+
+

A list of local directories that should be scanned for yaml and/or json files to be included in the static model.

+
+
security-scheme

Add a certain SecurityScheme with config. (basic, jwt, oidc, oauth2Implicit)

-
security-scheme-name
+
security-scheme-name

Add a Security Scheme name to the generated OpenAPI document. (default: SecurityScheme)

-
security-scheme-description
+
security-scheme-description

Add a description to the Security Scheme. (default: Authentication)

-
basic-security-scheme-value
+
basic-security-scheme-value

Add a scheme value to the Basic HTTP Security Scheme. (default: basic)

-
jwt-security-scheme-value
+
jwt-security-scheme-value

Add a scheme value to the JWT Security Scheme. (default: bearer)

-
jwt-bearer-format
+
jwt-bearer-format

Add a bearer format to the JWT Security Scheme. (default: JWT)

-
oidc-open-id-connect-url
+
oidc-open-id-connect-url

Add a openIdConnectUrl value to the OIDC Security Scheme

-
oauth2-implicit-refresh-url
+
oauth2-implicit-refresh-url

Add a implicit flow refreshUrl value to the OAuth2 Security Scheme

-
oauth2-implicit-authorization-url
+
oauth2-implicit-authorization-url

Add an implicit flow authorizationUrl value to the OAuth2 Security Scheme

-
oauth2-implicit-token-url
+
oauth2-implicit-token-url

Add an implicit flow tokenUrl value to the OAuth2 Security Scheme

+
open-api-version
+
+

Override the openapi version in the Schema document

+
+
info-title
+
+

Set the title in Info tag in the Schema document

+
+
info-version
+
+

Set the version in Info tag in the Schema document

+
+
info-description
+
+

Set the description in Info tag in the Schema document

+
+
info-terms-of-service
+
+

Set the terms of the service in Info tag in the Schema document

+
+
info-contact-email
+
+

Set the contact email in Info tag in the Schema document

+
+
info-contact-name
+
+

Set the contact name in Info tag in the Schema document

+
+
info-contact-url
+
+

Set the contact url in Info tag in the Schema document

+
+
info-license-name
+
+

Set the license name in Info tag in the Schema document

+
+
info-license-url
+
+

Set the license url in Info tag in the Schema document

+
+
operation-id-strategy
+
+

Set the strategy to automatically create an operation Id. Possible values: method,class-method, package-class-method

+

@@ -14024,8 +13761,11 @@

-
@Scheduled(cron = "{morning.check.cron.expr}")
-void morningTask() {}
+
@Scheduled(cron = "${morning.check.cron.expr}")
+void morningTask() {}
+
+@Scheduled(cron = "${myMethod.cron.expr:0 0 15 ? * MON *}")
+void myMethod() {}
+
+

Quarkus provides a built-in bean of type io.quarkus.scheduler.Scheduler:

+
+
+
+
@Inject
+io.quarkus.scheduler.Scheduler scheduler;
+
+
+scheduler.pause(); // Pause all
+scheduler.pause("myIdentity"); // Pause a specific scheduled method by its identity
+
+scheduler.resume("myIdentity");
+scheduler.resume()
+
+

Kogito

@@ -14070,6 +13828,39 @@

+
+

DevServices

+
+
+

When testing or running in dev mode Quarkus can even provide you with a zero config Kogito out of the box.

+
+
+

Possible configuration values prefixed with quarkus.kogito:

+
+
+
+
devservices.enabled
+
+

If devservices is enabled or not. (default: true)

+
+
devservices.image-name
+
+

The container image name to use instead of the default one. (default: quay.io/kiegroup/kogito-data-index-ephemeral)

+
+
devservices.port
+
+

Optional fixed port the dev service will listen to. (default: 8180)

+
+
devservices.shared
+
+

Indicates if the Data Index instance managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. (default: true)

+
+
devservices.service-name
+
+

The value of the kogito-dev-service-data-index label attached to the started container. (default: kogito-data-index)

+
+
+
+

eval

+
+
+
+
{#eval myData.template name='Mia' /}
+
+
+
+

The result of myData.template will be used as the template.

+
+

Message Bundling

+
+
+
@Inject
+CacheManager cacheManager;
+
+@Inject
+@CacheName("my-cache")
+Cache cache;
+
+public Uni<String> getNonBlockingExpensiveValue(Object key) {
+  return cache.get(key, k -> {
+  });
+}
+
+public String getBlockingExpensiveValue(Object key) {
+  return cache.get(key, k -> {
+  }).await().indefinitely(); (4)
+}
+
+
+

You can disable the caching system by setting quarkus.cache.enabled property to false.

+ +
+

Narayana LRA

+
+

The LRA (short for Long Running Action) participant extension is useful in microservice based designs where different services can benefit from a relaxed notion of distributed consistency.

+
+
+

The extension integrates with MicroProfile LRA

+
+
+
+
./mvnw quarkus:add-extension
+  -Dextensions="narayana-lra"
+
+
+
+

The only LRA specific property is quarkus.lra.coordinator-url=<url> which specifies the HTTP endpoint of an external coordinator,

+
+
+
+
@Path("/")
+@ApplicationScoped
+public class SimpleLRAParticipant
+{
+  @LRA(LRA.Type.REQUIRES_NEW)
+  @Path("/work")
+  @PUT
+  public void doInNewLongRunningAction(@HeaderParam(LRA_HTTP_CONTEXT_HEADER) URI lraId)
+  {
+  }
+
+  @org.eclipse.microprofile.lra.annotation.Complete
+  @Path("/complete")
+  @PUT
+  public Response completeWork(@HeaderParam(LRA_HTTP_CONTEXT_HEADER) URI lraId,
+                                 String userData)
+  {
+    return Response.ok(ParticipantStatus.Completed.name()).build();
+  }
+
+  @org.eclipse.microprofile.lra.annotation.Compensate
+  @Path("/compensate")
+  @PUT
+  public Response compensateWork(@HeaderParam(LRA_HTTP_CONTEXT_HEADER) URI lraId,
+                                   String userData)
+  {
+    return Response.ok(ParticipantStatus.Compensated.name()).build();
+  }
+}
+
+
+
+

@LRA can be used in differrent methods, so it’s started in one method and finished in another resource using end attribute:

+
+
+
+
@LRA(value = LRA.Type.REQUIRED, // if there is no incoming context a new one is created
+      cancelOn = {
+        Response.Status.INTERNAL_SERVER_ERROR // cancel on a 500 code
+      },
+      cancelOnFamily = {
+        Response.Status.Family.CLIENT_ERROR // cancel on any 4xx code
+      },
+    end = false) // the LRA will continue to run when the method finishes
+
+@LRA(LRA.Type.MANDATORY, // requires an active context before method can be executed
+      end = true)
+
+
@@ -15498,7 +15392,7 @@

-If you scaffold the project with spring-web extension, then Spring Web annotations are sed in the generated project. mvn io.quarkus:quarkus-maven-plugin:1.13.0.Final:create …​ -Dextensions="spring-web". +If you scaffold the project with spring-web extension, then Spring Web annotations are sed in the generated project. mvn io.quarkus:quarkus-maven-plugin:2.7.0.Final:create …​ -Dextensions="spring-web".
diff --git a/examples/quarkus-cheat-sheet/attributes.adoc b/examples/quarkus-cheat-sheet/attributes.adoc index dafe8699..91a9b616 100644 --- a/examples/quarkus-cheat-sheet/attributes.adoc +++ b/examples/quarkus-cheat-sheet/attributes.adoc @@ -1,9 +1,9 @@ :logo: quarkus.png -:version: 1.13.0.Final +:version: 2.7.0.Final :source-highlighter: highlightjs :sectlinks: :linkattrs: :sectanchors: :toc: macro :nofooter: -:pdf-download: https://github.com/lordofthejars/quarkus-cheat-sheet/releases/download/1.0.24/quarkus-cheat-sheet.pdf \ No newline at end of file +:pdf-download: https://github.com/lordofthejars/quarkus-cheat-sheet/releases/download/1.0.25/quarkus-cheat-sheet.pdf \ No newline at end of file diff --git a/examples/quarkus-cheat-sheet/cloud.adoc b/examples/quarkus-cheat-sheet/cloud.adoc index 3d38b2e5..22590515 100644 --- a/examples/quarkus-cheat-sheet/cloud.adoc +++ b/examples/quarkus-cheat-sheet/cloud.adoc @@ -26,6 +26,8 @@ Now `docker` (default) and `podman` are the valid options. To configure native application, you can create a `config` directory at the same place as the native file and place an `application.properties` file inside. `config/application.properties`. // end::update_1_6[] +To produce a native executable with native excutable use `-Dquarkus.native.additional-build-args=-J--enable-preview`. + *SSL* // tag::update_14_28[] @@ -244,6 +246,9 @@ Boolean to set if image should be built. (default: `false`) `push`:: Boolean to set if image should be pushed. (default: `false`) +`labels`:: +Custom labels to add to the generated image. + *Jib* [source, bash] @@ -281,8 +286,8 @@ A custom entry point of the container image in JVM mode. A custom entry point of the container image in native mode. // end::update_17_7[] -`labels`:: -Custom labels to add to the generated image. +`offline-mode`:: +Whether or not to operate offline. (default: `false`) `base-registry-username`:: The username to use to authenticate with the registry used to pull the base JVM image. @@ -305,6 +310,9 @@ When AppCDS generation is enabled, if this property is set, then the JVM used to `platforms`:: List of target platforms. (ie `linux/amd64`). +`docker-executable-ame`:: +Name of binary used to execute the docker commands. + *Docker* [source, bash] @@ -321,6 +329,43 @@ Path to the JVM Dockerfile. (default: `${project.root}/src/main/docker/Dockerfil `dockerfile-native-path`:: Path to the native Dockerfile. (default: `${project.root}/src/main/docker/Dockerfile.native`) +*Buildpacks* + +[source, bash] +---- +./mvnw quarkus:add-extensions + -Dextensions="quarkus-container-image-buildpack" +---- + +Prefix is `quarkus.buildpack`: + +`jvm-builder-image`:: +The buildpacks builder image to use when building the project in jvm mode. + +`native-builder-image`:: +The buildpacks builder image to use when building the project in native mode. + +`builder-env`:: +Environment key/values to pass to buildpacks. + +`run-image`:: +The buildpacks run image to use when building the project. + +`pull-timeout-seconds`:: +Max pull timeout for builder/run images, in seconds (default: `300`) + +`docker-host`:: +DOCKER_HOST value to use. + +`log-level`:: +Log level to use. (default `info`) + +`base-registry-username`:: +The username to use to authenticate with the registry used to pull the base image. + +`base-registry-password`:: +The password to use to authenticate with the registry used to pull the base image. + *S2I* [source, bash] @@ -516,6 +561,7 @@ The following Quarkus extensions support this feature: * quarkus-jdbc-postgresql * quarkus-kafka-client * quarkus-smallrye-reactive-messaging-kafka +* quarkus-mongodb [source, bash] ---- @@ -523,7 +569,7 @@ The following Quarkus extensions support this feature: -Dextensions="quarkus-kubernetes-service-binding" ---- -Datasource configuration part is absent as it is aut-discovered by Quarkus. +Datasource configuration part is absent as it is auto-discovered by Quarkus. // end::update_24_7[] == Minikube diff --git a/examples/quarkus-cheat-sheet/core.adoc b/examples/quarkus-cheat-sheet/core.adoc index 7bbc0fec..ef3c5e17 100644 --- a/examples/quarkus-cheat-sheet/core.adoc +++ b/examples/quarkus-cheat-sheet/core.adoc @@ -156,6 +156,37 @@ String[] args; ---- // end::update_15_16[] +*Testing* + +Command Mode applications can be tested using the `@QuarkusMainTest` and `@QuarkusMainIntegrationTest` annotations. + +[source, java] +---- +import io.quarkus.test.junit.main.Launch; +import io.quarkus.test.junit.main.LaunchResult; +import io.quarkus.test.junit.main.QuarkusMainLauncher; +import io.quarkus.test.junit.main.QuarkusMainTest; + +@QuarkusMainTest +public class HelloTest { + @Test + @Launch("World") + public void testLaunchCommand(LaunchResult result) { + Assertions.assertEquals("Hello World", result.getOutput()); + } + @Test + @Launch(value = {}, exitCode = 1) + public void testLaunchCommandFailed() { + } + @Test + public void testManualLaunch(QuarkusMainLauncher launcher) { + LaunchResult result = launcher.launch("Everyone"); + Assertions.assertEquals(0, result.exitCode()); + Assertions.assertEquals("Hello Everyone", result.getOutput()); + } +} +---- + // tag::update_16_15[] *Picocli* @@ -303,6 +334,20 @@ Endpoints are registered automatically to provide some basic debug info in dev m * `HTTP GET /quarkus/arc/observers` // end::update_17_14[] +== Dev Services + +Quarkus supports the automatic provisioning of unconfigured services in development and test mode. + +General configuration properties: + +`quarkus.devservices.enabled`:: +If you want to disable all Dev Services. (default: `true`) + +`quarkus.devservices.timeout`:: +Startup timeout. (default: `60S`) + +Set `DOCKER_HOST` env var to a remote Docker Host to use it instead the local one. + == Dev UI // tag::update_22_11[] @@ -311,6 +356,17 @@ Quarkus adds a Dev UI console to expose extension features. The Dev UI is available in dev mode only and accessible at the `/q/dev` endpoint by default. // end::update_22_11[] +== Continuous Testing + +Quarkus supports continuous testing, where tests run immediately after code changes have been saved. This allows you to get instant feedback on your code changes. Quarkus detects which tests cover which code, and uses this information to only run the relevant tests when code is changed. + +Start Quarkus in Dev Mode to run it. + +Also, you can start continuous testing and not dev mode by running `mvn quarkus:test`. + +`quarkus.test.exclude-pattern`:: +Tests that should be excluded with continuous testing default: `.*\.IT[^.]+|.*IT|.*ITCase` + == Adding Configuration Parameters To add configuration to your application, Quarkus relies on https://github.com/eclipse/microprofile-config[MicroProfile Config, window="_blank"] spec. @@ -460,6 +516,18 @@ This class maps `greeting.message` property defined in `application.properties`. You can inject this class by using CDI `@Inject GreetingConfiguration greeting;`. +`@IfBuildProfile`, `@UnlessBuildProfile`, `@IfBuildProperty` and `@UnlessBuildProperty` annotations are used to define when configuration properties are valid. + +[source, java] +---- +@UnlessBuildProfile("test") +@ConfigProperties +public class ServiceConfiguration { + public String user; + public String password; +} +---- + Also you can use an interface approach: [source, java] @@ -770,6 +838,21 @@ Message message; ---- // end::update_15_10[] +`@LookupIfProperty` indicates that a bean should only be obtained if a runtime configuration property matches the provided value. +`@LookupUnlessProperty`, on the other hand, indicates that a bean should only be obtained if a runtime configuration property does not match the provided value. + +[source, java] +---- +@LookupIfProperty(name = "service.foo.enabled", stringValue = "true") +@ApplicationScoped +class ServiceFoo implements Service { + + public String name() { + return "foo"; + } +} +---- + *Alternatives* // tag::update_15_11[] @@ -1167,6 +1250,9 @@ Minimum log level (default: `INFO`) `console.color`:: Allow color rendering (default: `true`) +`console.stderr`:: +If console logging should go to System#err instead of System#out (default: `false`) + `file.enable`:: File logging enabled (default: `false`) @@ -1756,6 +1842,22 @@ public class MyCustomTestResource public int order() { return 0; } + + // optional + @Override + public void setContext(Context context) { + } + + @Override + public void inject(TestInjector testInjector) { + testInjector.injectIntoFields(wireMockServer, + new TestInjector.AnnotatedAndMatchesType(InjectWireMock.class, WireMockServer.class)); + } +} + +public class MyTest { + @InjectWireMock + WireMockServer wireMockServer; } ---- @@ -1847,6 +1949,8 @@ public class ExampleResource { Mock is automatically injected and only valid for the defined test class. +`@InjectMock` has `convertScopes` parameter that if true, then Quarkus will change the scope of the target from `Singleton` bean to `ApplicationScoped` to make the mockable. + // tag::update_16_25[] Also `spy` is supported: @@ -1899,6 +2003,34 @@ public class TestStereotypeTestCase {} ---- // end::update_5_5[] +*Decorator* + +Quarkus also supports CDI Decorators: + +[source, java] +---- +@Priority(10) +@Decorator +public class LargeTxAccount implements Account { + + @Inject + @Any + @Delegate + Account delegate; + + @Inject + LogService logService; + + void withdraw(BigDecimal amount) { + delegate.withdraw(amount); + if (amount.compareTo(1000) > 0) { + logService.logWithdrawal(delegate, amount); + } + } + +} +---- + *Test Coverage* // tag::update_6_3[] @@ -1949,4 +2081,6 @@ To test native executables annotate the test with `@NativeImageTest`. // tag::update_24_2[] `@QuarkusIntegrationTest` should be used to launch and test the artifact produced by the Quarkus build. If the result of a Quarkus build is a JAR then the app is launched as `java -jar`, if native is launched as `./application`, if container image is created (JiB, Docker extensions) is launched as `docker run`. + +You can connect to already running application by using the following properties: `quarkus.http.test-host=1.2.3.4` `quarkus.http.test-port=4321` // end::update_24_2[] diff --git a/examples/quarkus-cheat-sheet/misc.adoc b/examples/quarkus-cheat-sheet/misc.adoc index ddbc9563..527491fd 100644 --- a/examples/quarkus-cheat-sheet/misc.adoc +++ b/examples/quarkus-cheat-sheet/misc.adoc @@ -13,6 +13,8 @@ Quarkus can be used to handling web sockets. -Dextensions="quarkus-websockets" ---- +If you only want the client you can include `quarkus-websockets-client`. + And web sockets classes can be used: [source, java] @@ -216,43 +218,84 @@ You can store generated OpenAPI schema if `quarkus.swagger-ui.store-schema-direc // tag::update_24_4[] Possible OpenAPI options with `quarkus.smallrye-openapi` prefix: -path:: +`path`:: The path at which to register the OpenAPI Servlet. (default: `openapi`) -store-schema-directory:: +`store-schema-directory`:: The generated OpenAPI schema documents will be stored here on build. -security-scheme:: +`always-run-filter`:: +Do not run the filter only at startup, but every time the document is requested (dynamic). (default: `false`) + +`ignore-static-document`:: +Do not include the provided static openapi document. (default: `false`) + +`additional-docs-directory`:: +A list of local directories that should be scanned for yaml and/or json files to be included in the static model. + +`security-scheme`:: Add a certain SecurityScheme with config. (`basic`, `jwt`, `oidc`, `oauth2Implicit`) -security-scheme-name:: +`security-scheme-name`:: Add a Security Scheme name to the generated OpenAPI document. (default: `SecurityScheme`) -security-scheme-description:: +`security-scheme-description`:: Add a description to the Security Scheme. (default: `Authentication`) -basic-security-scheme-value:: +`basic-security-scheme-value`:: Add a scheme value to the Basic HTTP Security Scheme. (default: `basic`) -jwt-security-scheme-value:: +`jwt-security-scheme-value`:: Add a scheme value to the JWT Security Scheme. (default: `bearer`) -jwt-bearer-format:: +`jwt-bearer-format`:: Add a bearer format to the JWT Security Scheme. (default: `JWT`) -oidc-open-id-connect-url:: +`oidc-open-id-connect-url`:: Add a openIdConnectUrl value to the OIDC Security Scheme -oauth2-implicit-refresh-url:: +`oauth2-implicit-refresh-url`:: Add a implicit flow refreshUrl value to the OAuth2 Security Scheme -oauth2-implicit-authorization-url:: +`oauth2-implicit-authorization-url`:: Add an implicit flow authorizationUrl value to the OAuth2 Security Scheme -oauth2-implicit-token-url:: +`oauth2-implicit-token-url`:: Add an implicit flow tokenUrl value to the OAuth2 Security Scheme // end::update_24_4[] +`open-api-version`:: +Override the openapi version in the Schema document + +`info-title`:: +Set the title in Info tag in the Schema document + +`info-version`:: +Set the version in Info tag in the Schema document + +`info-description`:: +Set the description in Info tag in the Schema document + +`info-terms-of-service`:: +Set the terms of the service in Info tag in the Schema document + +`info-contact-email`:: +Set the contact email in Info tag in the Schema document + +`info-contact-name`:: +Set the contact name in Info tag in the Schema document + +`info-contact-url`:: +Set the contact url in Info tag in the Schema document + +`info-license-name`:: +Set the license name in Info tag in the Schema document + +`info-license-url`:: +Set the license url in Info tag in the Schema document + +`operation-id-strategy`:: +Set the strategy to automatically create an operation Id. Possible values: `method`,`class-method`, `package-class-method` == Mail Sender // tag::update_2_5[] @@ -449,8 +492,11 @@ public class CounterBean { [source java] ---- -@Scheduled(cron = "{morning.check.cron.expr}") +@Scheduled(cron = "${morning.check.cron.expr}") void morningTask() {} + +@Scheduled(cron = "${myMethod.cron.expr:0 0 15 ? * MON *}") +void myMethod() {} ---- And configure the property into `application.properties`: @@ -458,6 +504,8 @@ And configure the property into `application.properties`: [source, properties] ---- morning.check.cron.expr=0 15 10 * * ? + +morning.check.cron.expr=disabled ---- // end::update_3_2[] @@ -482,6 +530,20 @@ quartz.scheduleJob(job, trigger); ---- // end::update_14_18[] +Quarkus provides a built-in bean of type `io.quarkus.scheduler.Scheduler`: + +[source, java] +---- +@Inject +io.quarkus.scheduler.Scheduler scheduler; + + +scheduler.pause(); // Pause all +scheduler.pause("myIdentity"); // Pause a specific scheduled method by its identity + +scheduler.resume("myIdentity"); +scheduler.resume() +---- == Kogito // tag::update_3_9[] @@ -496,6 +558,27 @@ To start using it you only need to add the next extension: ---- // end::update_3_9[] +*DevServices* + +When testing or running in dev mode Quarkus can even provide you with a zero config Kogito out of the box. + +Possible configuration values prefixed with `quarkus.kogito`: + +`devservices.enabled`:: +If devservices is enabled or not. (default: `true`) + +`devservices.image-name`:: +The container image name to use instead of the default one. (default: `quay.io/kiegroup/kogito-data-index-ephemeral`) + +`devservices.port`:: +Optional fixed port the dev service will listen to. (default: `8180`) + +`devservices.shared`:: +Indicates if the Data Index instance managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. (default: `true`) + +`devservices.service-name`:: +The value of the `kogito-dev-service-data-index` label attached to the started container. (default: `kogito-data-index`) + == Apache Tika // tag::update_5_8[] @@ -945,6 +1028,15 @@ The next number methods are supported: Following operators can be used either in `when` and `switch`: `not, ne, !=`, `gt, >`, `ge, >=`, `lt, <`, `le, \<=`, `in`, `ni, !in`. // end::update_22_3[] +*eval* + +[source, html] +---- +{#eval myData.template name='Mia' /} +---- + +The result of `myData.template` will be used as the template. + *Message Bundling* // tag::update_20_5[] @@ -1179,6 +1271,28 @@ public class CachedBean { } ---- +*Programmatic API* + +[source, java] +---- +@Inject +CacheManager cacheManager; + +@Inject +@CacheName("my-cache") +Cache cache; + +public Uni getNonBlockingExpensiveValue(Object key) { + return cache.get(key, k -> { + }); +} + +public String getBlockingExpensiveValue(Object key) { + return cache.get(key, k -> { + }).await().indefinitely(); //<4> +} +---- + // tag::update_19_1[] You can disable the caching system by setting `quarkus.cache.enabled` property to `false`. // end::update_19_1[] @@ -1534,4 +1648,68 @@ A Maven goal is provided to scaffold a project: ---- mvn io.quarkus:quarkus-maven-plugin::create-jbang ---- -// end::update_22_6[] \ No newline at end of file +// end::update_22_6[] + +== Narayana LRA + +The LRA (short for Long Running Action) participant extension is useful in microservice based designs where different services can benefit from a relaxed notion of distributed consistency. + +The extension integrates with https://github.com/eclipse/microprofile-lra/blob/master/spec/src/main/asciidoc/microprofile-lra-spec.adoc#eclipse-microprofile-lra[MicroProfile LRA] + +[source, bash] +---- +./mvnw quarkus:add-extension + -Dextensions="narayana-lra" +---- + +The only LRA specific property is `quarkus.lra.coordinator-url=` which specifies the HTTP endpoint of an external coordinator, + +[source, java] +---- +@Path("/") +@ApplicationScoped +public class SimpleLRAParticipant +{ + @LRA(LRA.Type.REQUIRES_NEW) + @Path("/work") + @PUT + public void doInNewLongRunningAction(@HeaderParam(LRA_HTTP_CONTEXT_HEADER) URI lraId) + { + } + + @org.eclipse.microprofile.lra.annotation.Complete + @Path("/complete") + @PUT + public Response completeWork(@HeaderParam(LRA_HTTP_CONTEXT_HEADER) URI lraId, + String userData) + { + return Response.ok(ParticipantStatus.Completed.name()).build(); + } + + @org.eclipse.microprofile.lra.annotation.Compensate + @Path("/compensate") + @PUT + public Response compensateWork(@HeaderParam(LRA_HTTP_CONTEXT_HEADER) URI lraId, + String userData) + { + return Response.ok(ParticipantStatus.Compensated.name()).build(); + } +} +---- + +`@LRA` can be used in differrent methods, so it's started in one method and finished in another resource using `end` attribute: + +[source, java] +---- +@LRA(value = LRA.Type.REQUIRED, // if there is no incoming context a new one is created + cancelOn = { + Response.Status.INTERNAL_SERVER_ERROR // cancel on a 500 code + }, + cancelOnFamily = { + Response.Status.Family.CLIENT_ERROR // cancel on any 4xx code + }, + end = false) // the LRA will continue to run when the method finishes + +@LRA(LRA.Type.MANDATORY, // requires an active context before method can be executed + end = true) +---- \ No newline at end of file diff --git a/examples/quarkus-cheat-sheet/network.adoc b/examples/quarkus-cheat-sheet/network.adoc index f9c5b9b0..00d126da 100644 --- a/examples/quarkus-cheat-sheet/network.adoc +++ b/examples/quarkus-cheat-sheet/network.adoc @@ -4,11 +4,14 @@ You can configure HTTP parameters. Using `quarkus.http` prefix: +`http.access-log.exclude-pattern`:: +A regular expression that can be used to exclude some paths from logging + `cors`:: Enable CORS. (default: `false`) `cors.origins`:: -CSV of origins allowed. (dedault: Any request valid.) +CSV of origins allowed. Regular expressions are also allowed (dedault: Any request valid.) `cors.methods`:: CSV of methods valid. (default: Any method valid.) @@ -35,13 +38,7 @@ Enable listening to host:port. (default: `true`) The HTTPS port. (default `8443`) `test-ssl-port`:: -The HTTPS port used to run tests. (default `8444`) - -`proxy-address-forwarding`:: -The address, scheme etc will be set from headers forwarded by the proxy server. - -`allow-forwarded`:: -Proxy address forwarding is enabled then the standard `Forwarded` header will be used, rather than the more common but not standard `X-Forwarded-For`. +The HTTPS port used to run tests. (default: `8444`) `insecure-requests`:: If insecure requests are allowed. Possible values: `enabled`, `redirect`, `disable`. (default: `enabled`) @@ -49,27 +46,45 @@ If insecure requests are allowed. Possible values: `enabled`, `redirect`, `disab `http2`:: Enables HTTP/2. (default: `true`) +`proxy.proxy-address-forwarding`:: +The address, scheme etc will be set from headers forwarded by the proxy server. + +`proxy.allow-forwarded`:: +Proxy address forwarding is enabled then the standard `Forwarded` header will be used, rather than the more common but not standard `X-Forwarded-For`. + +`proxy.enable-forwarded-host`:: +Enable override the received request’s host through a forwarded host header + +`proxy.forwarded-host-header`:: +Configure the forwarded host header to be used if override enabled + `ssl.port`:: The _HTTPS_ port. (default: `8443`) -`ssl.certificate.file`:: -The file path to a service certificate or certificate chain in _PEM_ format. Relative to `src/main/resources`. +`ssl.certificate.files`:: +The files path to a service certificate or certificate chain in _PEM_ format. Relative to `src/main/resources`. -`ssl.certificate.key-file`:: -The file path to the corresponding certificate private key in _PEM_ format. Relative to `src/main/resources`. +`ssl.certificate.key-files`:: +The files path to the corresponding certificate private key in _PEM_ format. Relative to `src/main/resources`. `ssl.certificate.key-store-file`:: The key store contains the certificate information. Relative to `src/main/resources`. +`ssl.certificate.key-store-key-alias`:: +An optional parameter to select a specific key in the key store. + `ssl.certificate.key-store-file-type`:: The key store type. It is automatically detected based on the file name or can be set manually. Supported values are: `JKS`, `JCEKS`, `P12`, `PKCS12` or `PFX`. `ssl.certificate.key-store-password`:: The password to open the key store file. -`ssl.certificate.trust-store-file` +`ssl.certificate.trust-store-file`:: The trust store location which contains the certificate information of the certificates to trust. Relative to `src/main/resources`. +`ssl.certificate.trust-store-cert-alias`:: +An optional parameter to trust only one specific certificate in the trust store + `ssl.certificate.trust-store-file-type`:: The trust store type. It is automatically detected based on the file name or can be set manually. @@ -82,6 +97,9 @@ A list of strings of cipher suites to use. If not provided, a reasonable default `ssl.protocols`:: The list of protocols to explicitly enable. (default: `TLSv1.3` and `TLSv1.2`). +`ssl.sni`:: +Enables Server Name Indication (SNI), an TLS extension allowing the server to use multiple certificates. (default: `false`) + `ssl.client-auth`:: Configures the engine to require/request client authentication. Possible values are: `none`, `request` and `required`. (default: `none`). @@ -505,10 +523,71 @@ Always include the UI. By default this will only be included in dev and test. (d `enable-ui`:: If GraphQL UI should be enabled. (default: `false`) +`schema-available`:: +Make the schema available over HTTP. (default: `true`) + `metrics.enabled`:: Enable metrics. (default: `false`) // end::update_16_12[] +*GraphQL Clients* + + +[source, bash] +---- +./mvnw quarkus:add-extension + -Dextensions="graphql-client" +---- + +[source, properties] +---- +quarkus.smallrye-graphql-client.star-wars.url=https://swapi-graphql.netlify.app/.netlify/functions/index +---- + +_Typesafe client_ + +[source, java] +---- +@GraphQLClientApi(configKey = "star-wars") +public interface StarWarsClientApi { + + FilmConnection allFilms(); + +} + +@Inject +StarWarsClientApi typesafeClient; +---- + +`allFilms` is also the name of the query. +You can override the value using `@Query(value="allStarWarsFilms")` + + +_Dynamic client_ + +[source, java] +---- +@Inject +@GraphQLClient("star-wars") +DynamicGraphQLClient dynamicClient; + +Document query = document( + operation( + field("allFilms", + field("films", + field("title"), + field("planetConnection", + field("planets", + field("name") + ) + ) + ) + ) + ) + ); +Response response = dynamicClient.executeSync(query) +---- + == Vert.X Verticle // tag::update_14_1[] @@ -632,15 +711,41 @@ The path to the certificate file. `transport-security.key`:: The path to the private key file. +`load-balancing-policy`:: +Use a custom load balancing policy. Possible values: `pick_first`, `round_robin`, `grpclb`. (default: `pick_first`) + To consume the service: [source, java] ---- -@GrpcService("hello") +@GrpcClient("hello") GreeterGrpc.GreeterBlockingStub client; -@GrpcService("hello") +@GrpcClient("hello") io.grpc.Channel channel; + +// Adding headers + +Metadata extraHeaders = new Metadata(); +extraHeaders.put("my-header", "my-interface-value"); + +GreeterBlockingStub alteredClient = io.quarkus.grpc.GrpcClientUtils.attachHeaders(client, extraHeaders); +---- + +*Interceptors* + +[source, java] +---- +import io.quarkus.grpc.GlobalInterceptor; +import io.grpc.ClientInterceptor; + +@GlobalInterceptor +@ApplicationScoped +public class MyInterceptor implements ClientInterceptor {} + +@RegisterClientInterceptor(MySpecialInterceptor.class) <1> +@GrpcClient("helloService") +Greeter greeter; ---- Some configuration example to set the host and the SSL parameters: @@ -655,6 +760,96 @@ quarkus.grpc.clients.hello.ssl.trust-store=src/main/resources/tls/ca.pem ---- // end::update_16_8[] +== Smallrye Stork + +https://smallrye.io/smallrye-stork/1.0.0/[Stork] implements client load-balancing strategies supporting Kubernetes, and Consul. + +*Consul* + +Add following dependencies: + +[source, xml] +---- + + io.smallrye.stork + stork-service-discovery-consul + + + io.smallrye.reactive + smallrye-mutiny-vertx-consul-client + +---- + +Register service instances to Consul: + +[source, java] +---- +@ApplicationScoped +public class Registration { + + @ConfigProperty(name = "consul.host") String host; + @ConfigProperty(name = "consul.port") int port; + + public void init(@Observes StartupEvent ev, Vertx vertx) { + ConsulClient client = ConsulClient.create(vertx, + new ConsulClientOptions().setHost(host).setPort(port)); + + client.registerServiceAndAwait( + new ServiceOptions().setPort(8080) + .setAddress("host1").setName("my-service").setId("blue")); + client.registerServiceAndAwait( + new ServiceOptions().setPort(8080) + .setAddress("host2").setName("my-service").setId("red")); + + } +} +---- + +Configuration: + +[source, properties] +---- +consul.host=localhost +consul.port=8500 + +stork.my-service.service-discovery=consul +stork.my-service.service-discovery.consul-host=localhost +stork.my-service.service-discovery.consul-port=8500 +stork.my-service.load-balancer=round-robin +---- + +*Kubernetes* + +Add following dependencies: + +[source, xml] +---- + + io.smallrye.reactive + stork-service-discovery-kubernetes + +---- + +[source, properties] +---- +stork.my-service.service-discovery=kubernetes +stork.my-service.service-discovery.k8s-namespace=my-namespace +stork.my-service.load-balancer=round-robin +---- + +*Using Stork at client* + +[source, java] +---- +@RegisterRestClient(baseUri = "stork://my-service") +public interface MyService { + + @GET + @Produces(MediaType.TEXT_PLAIN) + String get(); +} +---- + == Fault Tolerance // tag::update_1_2[] Quarkus uses https://github.com/eclipse/microprofile-fault-tolerance[MicroProfile Fault Tolerance, window="_blank"] spec: @@ -737,6 +932,20 @@ It can be used together with any other fault tolerance annotation. WorldClock getNow(){} ---- +From smallrye project Fibonacci and Exponential Backoff retries annotations are provided: + +[source, java] +---- +public class TwoBackoffsOnMethodService { + @Retry + @io.smallrye.faulttolerance.api.ExponentialBackoff + @io.smallrye.faulttolerance.api.FibonacciBackoff + public void hello() { + throw new IllegalArgumentException(); + } +} +---- + Fault tolerance annotations: |=== @@ -925,6 +1134,9 @@ You can disable the automatic generation by setting `.health.enabled` [source, properties] ---- +quarkus.datasource.myotherdatasource.health-exclude=true +quarkus.datasource.health.enabled=true + quarkus.kafka-streams.health.enabled=false quarkus.mongodb.health.enabled=false quarkus.neo4j.health.enabled=false @@ -962,6 +1174,23 @@ quarkus.smallrye-health.group-path=/customgroup ---- // end::update_15_5[] +MicroProfile Health currently doesn't support returning reactive types, but SmallRye Health does. +Implement the `io.smallrye.health.api.AsyncHealthCheck` interface instead of the `org.eclipse.microprofile.health.HealthCheck`. + +[source, java] +---- +@Liveness +@ApplicationScoped +public class LivenessAsync implements AsyncHealthCheck { + @Override + public Uni call() { + return Uni.createFrom().item(HealthCheckResponse.up("liveness-reactive")) + .onItem().delayIt().by(Duration.ofMillis(10)); + } +} +---- + + *Metrics* Quarkus can utilize the https://github.com/eclipse/microprofile-metrics[MicroProfile Metrics spec, window="_blank"] to provide metrics support. @@ -1255,10 +1484,86 @@ quarkus.hibernate-orm.dialect= *OpenTelemetry* -// tag::update_24_6[] -Quarkus integrates with the OpenTelemetry project. -For exporting traces to a Jaeger collector, use the `quarkus-opentelemetry-exporter-jaeger` extension. -// end::update_24_6[] +[source, bash] +---- +./mvnw quarkus:add-extension + -Dextensions="opentelemetry-otlp-exporter" +---- + +Possible configuration: + +[source, properties] +---- +quarkus.application.name=myservice +quarkus.opentelemetry.enabled=true +quarkus.opentelemetry.tracer.exporter.otlp.endpoint=http://localhost:4317 + +quarkus.opentelemetry.tracer.exporter.otlp.headers=Authorization=Bearer my_secret +---- + +The OpenTelemetry extension enables the W3C Trace Context and the W3C Baggage propagators, you can however choose any of the supported OpenTelemetry propagators. + +The `b3`, `b3multi`, `jaeger` and `ottrace` propagators: + +[source, xml] +---- + + io.opentelemetry + opentelemetry-extension-trace-propagators + +---- + +The `xray` propagator: + +[source, xml] +---- + + io.opentelemetry + opentelemetry-extension-aws + +---- + +You can configure OpenTelemetry. +Prefix is `quarkus.opentelemetry`: + +`enabled`:: +OpenTelemetry support (default: `true`) + +`propagators`:: +Comma separated list of OpenTelemetry propagators which must be supported. Possible values b3, b3multi, baggage, jaeger, ottrace, tracecontext, xray (default: `traceContext`,`baggage`). + +`tracer.enabled`:: +Support for tracing with OpenTelemetry. + +`tracer.resource-attributes`:: +A comma separated list of name=value resource attributes that represents the entity producing telemetry + +`tracer.sampler`:: +The sampler to use for tracing. Possible values `off`, `on`, `ratio`. (Default: `on`) + +`tracer.sampler.ratio`:: +Ratio to sample + +`tracer.sampler.parent-based`:: +If the sampler to use for tracing is parent based (default: `true`) + +`tracer.suppress-non-application-uris`:: +Suppress non-application uris from trace collection. (default: `true`) + +`tracer.exporter.otlp.enabled`:: +OTLP SpanExporter support (default: `true`) + +tracer.exporter.otlp.endpoint:: +The OTLP endpoint to connect to + +`tracer.exporter.otlp.headers`:: +Key-value pairs to be used as headers associated with gRPC requests + +`tracer.exporter.otlp.export-timeout`:: +The maximum amount of time to wait for the collector to process exported spans before an exception is thrown. (default: `10S`) + +`tracer.exporter.otlp.compression`:: +Compression method to be used by exporter to compress the payload // tag::update_21_4[] *Kafka Tracer* diff --git a/examples/quarkus-cheat-sheet/persistence.adoc b/examples/quarkus-cheat-sheet/persistence.adoc index 761ec67b..c952fefe 100644 --- a/examples/quarkus-cheat-sheet/persistence.adoc +++ b/examples/quarkus-cheat-sheet/persistence.adoc @@ -133,6 +133,9 @@ Defines the method for multi-tenancy. Possible values: `DATABASE`, `NONE`, `SCHE `multitenant-schema-datasource`:: Defines the name of the data source to use in case of SCHEMA approach. +`metadata-builder-contributor`:: +Class name of a custom `org.hibernate.boot.spi.MetadataBuilderContributor` implementation. + `query.query-plan-cache-max-size`:: The maximum size of the query plan cache. @@ -157,6 +160,15 @@ Default Schema. `database.charset`:: Charset. +`scripts.generation`:: +Select whether the database schema DDL files are generated or not. Possible values: `none`, `create`, `drop-and-create`, `drop`, `update`. (default: `none`) + +`scripts.generation.create-target`:: +Filename or URL where the database create DDL file should be generated. + +`scripts.generation.drop-target`:: +Filename or URL where the database drop DDL file should be generated. + `jdbc.timezone`:: Time Zone JDBC driver. @@ -411,7 +423,6 @@ public void testPanacheMocking() { *DevServices* -// tag::update_24_1[] When testing or running in dev mode Quarkus can even provide you with a zero config database out of the box. Depending on your database type you may need docker installed in order to use this feature. @@ -444,8 +455,6 @@ The container image name to use instead of the default one. `devservices.properties`:: Generic properties that are added to the database connection URL. -// end::update_24_1[] - *DAO pattern* // tag::update_2_12[] @@ -536,6 +545,8 @@ public class FlywayTestResources { ---- // end::update_4_3[] + + *Transactions* // tag::update_6_4[] @@ -685,6 +696,24 @@ Quarkus supports Hibernate Envers. ./mvnw quarkus:add-extension -Dextensions="hibernate-envers" ---- + +Configuration properties prefixed with `quarkus.hibernate-envers`: + +`store-data-at-delete`:: +Enable store_data_at_delete feature. (default: `false`) + +`audit-table-suffix`:: +Defines a suffix for historical data table. (default: `_AUD`) + +`audit-table-prefix`:: +Defines a prefix for historical data table. (default: ``) + +`revision-field-name`:: +Revision field name. (default: `REV`) + +`revision-type-field-name`:: +Revision type field name. (default: `REVTYPE`) + // end::update_18_1[] == REST Data Panache @@ -784,6 +813,7 @@ public CompletionStage reactiveFind() { // end::update_17_4[] == Infinispan + // tag::update_8_7[] Quarkus integrates with https://infinispan.org/[Infinispan, window="_blank"]: @@ -951,6 +981,27 @@ org.infinispan.manager.EmbeddedCacheManager cacheManager; ---- // end::update_10_7[] +*DevServices* + +When testing or running in dev mode Quarkus can even provide you with a zero config Infinispan out of the box. + +Possible configuration values prefixed with `quarkus.infinispan-client`: + +`devservices.enabled`:: +If devservices is enabled or not. (default: `true`) + +`devservices.port`:: +Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly. + +`devservices.shared`:: +Indicates if the Infinispan managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. (default: `true`) + +`devservices.service-name`:: +The value of the `quarkus-dev-service-infinispan` label attached to the started container. (default: `infinispan`) + +`devservices.artifacts`:: +List of the artifacts to automatically download and add to the Infinispan server libraries. + == Redis // tag::update_18_4[] @@ -999,6 +1050,28 @@ Uni> keys() { } ---- +*DevServices* + +When testing or running in dev mode Quarkus can even provide you with a zero config Redis out of the box. + +Possible configuration values prefixed with `quarkus.redis`: + +`devservices.enabled`:: +If devservices is enabled or not. (default: `true`) + +`devservices.image-name`:: +The container image name to use instead of the default one. + +`devservices.port`:: +Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly. + +`devservices.shared`:: +Indicates if the Redis broker managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. (default: `true`) + +`devservices.service-name`:: +The value of the `quarkus-dev-service-redis` label attached to the started container. (default: `redis`) + + // tag::update_20_2[] *Multiple Redis Clients* @@ -1253,6 +1326,16 @@ quarkus.liquibase.inventory.schemas=INVENTORY_TEST_SCHEMA ---- // end::update_14_37[] +*Liquibase MongoDB* + +[source, bash] +---- +./mvnw quarkus:add-extension + -Dextensions="liquibase-mongodb" +---- + +Most of the configuration properties are valid but changing prefix to: `quarkus.liquibase-mongodb` + == Hibernate Search // tag::update_3_1[] @@ -1372,6 +1455,9 @@ Class or name of the neab used to configure. `hosts`:: List of Elasticsearch servers hosts. +`enabled`:: +Whether Hibernate Search is enabled. (default: `true`) + `username`:: Username for auth. @@ -1453,6 +1539,8 @@ How a dependency of the indexing process to a property should affect automatic r For `java.math.BigDecimal` or `java.math.BigInteger` that you need higher precision. // end::update_3_1[] +If you are using ElasticSearch in AWS you might need some extra config provided by an special extension https://quarkiverse.github.io/quarkiverse-docs/quarkus-hibernate-search-extras/dev/index.html + == Amazon DynamoDB // tag::update_5_6[] // tag::update_8_3[] @@ -1960,6 +2048,12 @@ public Publisher get() { ---- // end::update_14_19[] +*DevServices* + +When testing or running in dev mode Quarkus can even provide you with a zero config Neo4j out of the box. + +Possible configuration values are shown at https://quarkiverse.github.io/quarkiverse-docs/quarkus-neo4j/dev/index.html#dev-services[Neo4J, window="_blank"] + == MongoDB Client // tag::update_5_10[] Quarkus integrates with https://www.mongodb.com/[MongoDB, window="_blank"]: @@ -1989,6 +2083,21 @@ quarkus.mongodb.connection-string=mongodb://localhost:27018 quarkus.mongodb.write-concern.journal=false ---- +*Testing* + +To start an embedded MongoDB database for your unit tests, Quarkus provides two `QuarkusTestResourceLifecycleManager`. + +Add `io.quarkus:quarkus-test-mongodb` dependency. + +[source, java] +---- +// Single MongoDB instance +@QuarkusTestResource(io.quarkus.test.mongodb.MongoTestResource.class) + +// ReplicaSet with two instances +@QuarkusTestResource(io.quarkus.test.mongodb.MongoReplicaSetTestResource.class) +---- + *Multi MongoDB support* // tag::update_14_5[] @@ -2011,6 +2120,29 @@ MongoClient mongoClient1; ---- // end::update_14_5[] +*DevServices* + +When testing or running in dev mode Quarkus can even provide you with a zero config MongoDB database out of the box. + +[source, properties] +---- +%prod.quarkus.mongodb.connection-string=mongodb://localhost:27018 +---- + +Possible configuration values prefixed with `quarkus.datasource`: + +`devservices.enabled`:: +If devservices is enabled or not. (default: `true`) + +`devservices.image-name`:: +The container image name to use instead of the default one. + +`devservices.port`:: +Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly. + +`devservices.properties`:: +Generic properties that are added to the database connection URL. + <<< `quarkus.mongodb` as prefix is skipped in the following table. @@ -2146,6 +2278,10 @@ a|`String` a|`credentials.auth-mechanism-properties` a|`Map` |Authentication mechanism properties. + +a|`read-concern` +a|`String` +|Configures the read concern. Possible values: `local`, `majority`, `linearizable`, `snapshot`, `available` |=== // end::update_5_10[] @@ -2268,6 +2404,10 @@ PanacheQuery shortQuery = Person.find("status ", Status.Alive).proje <1> Entity class. // end::update_13_10[] +*Transsactions* + +To use them with MongoDB with Panache you need to annotate the method that starts the transaction with the `@Transactional` annotation. + *Testing* To mock using active record pattern: diff --git a/examples/quarkus-cheat-sheet/quarkus-cheat-sheet.html b/examples/quarkus-cheat-sheet/quarkus-cheat-sheet.html index a243e805..77141f58 100644 --- a/examples/quarkus-cheat-sheet/quarkus-cheat-sheet.html +++ b/examples/quarkus-cheat-sheet/quarkus-cheat-sheet.html @@ -470,7 +470,7 @@

Quarkus is a Kubernetes Native Java stack tailored for GraalVM & OpenJDK HotSpot, crafted from the best of breed Java libraries and standards. Also focused on developer experience, making things just work with little to no configuration and allowing to do live coding.

-

Cheat-sheet tested with Quarkus 1.13.0.Final.

+

Cheat-sheet tested with Quarkus 2.7.0.Final.

@@ -479,7 +479,7 @@

Quarkus comes with a Maven archetype to scaffold a very simple starting project.

-
mvn io.quarkus:quarkus-maven-plugin:1.13.0.Final:create \
+
mvn io.quarkus:quarkus-maven-plugin:2.7.0.Final:create \
     -DprojectGroupId=org.acme \
     -DprojectArtifactId=getting-started \
     -DclassName="org.acme.quickstart.GreetingResource" \
@@ -624,6 +624,35 @@ 

Testing

+

Command Mode applications can be tested using the @QuarkusMainTest and @QuarkusMainIntegrationTest annotations.

+
+
+
import io.quarkus.test.junit.main.Launch;
+import io.quarkus.test.junit.main.LaunchResult;
+import io.quarkus.test.junit.main.QuarkusMainLauncher;
+import io.quarkus.test.junit.main.QuarkusMainTest;
+
+@QuarkusMainTest
+public class HelloTest {
+    @Test
+    @Launch("World")
+    public void testLaunchCommand(LaunchResult result) {
+        Assertions.assertEquals("Hello World", result.getOutput());
+    }
+    @Test
+    @Launch(value = {}, exitCode = 1)
+    public void testLaunchCommandFailed() {
+    }
+    @Test
+    public void testManualLaunch(QuarkusMainLauncher launcher) {
+        LaunchResult result = launcher.launch("Everyone");
+        Assertions.assertEquals(0, result.exitCode());
+        Assertions.assertEquals("Hello Everyone", result.getOutput());
+    }
+}
+
+

Picocli

You can use Picocli to implement CLI applications:

+

Dev Services

+
+

Quarkus supports the automatic provisioning of unconfigured services in development and test mode.

+

General configuration properties:

+
+
+
quarkus.devservices.enabled
+
+

If you want to disable all Dev Services. (default: true)

+
+
quarkus.devservices.timeout
+
+

Startup timeout. (default: 60S)

+
+
+
+

Set DOCKER_HOST env var to a remote Docker Host to use it instead the local one.

+
+
+

Dev UI

Quarkus adds a Dev UI console to expose extension features.

@@ -801,6 +850,22 @@

+

Continuous Testing

+
+

Quarkus supports continuous testing, where tests run immediately after code changes have been saved. This allows you to get instant feedback on your code changes. Quarkus detects which tests cover which code, and uses this information to only run the relevant tests when code is changed.

+

Start Quarkus in Dev Mode to run it.

+

Also, you can start continuous testing and not dev mode by running mvn quarkus:test.

+
+
+
quarkus.test.exclude-pattern
+
+

Tests that should be excluded with continuous testing default: .*\.IT[^.]+|.*IT|.*ITCase

+
+
+
+
+

+

+

@LookupIfProperty indicates that a bean should only be obtained if a runtime configuration property matches the provided value. +@LookupUnlessProperty, on the other hand, indicates that a bean should only be obtained if a runtime configuration property does not match the provided value.

+
+
+
@LookupIfProperty(name = "service.foo.enabled", stringValue = "true")
+@ApplicationScoped
+class ServiceFoo implements Service {
+
+    public String name() {
+       return "foo";
+    }
+}
+
+

Alternatives

It is also possible to select alternatives for an application using application.properties.

@@ -1683,6 +1773,10 @@

console.stderr +
+

If console logging should go to System#err instead of System#out (default: false)

+
file.enable

File logging enabled (default: false)

@@ -2296,6 +2390,22 @@

Mock is automatically injected and only valid for the defined test class.

+

@InjectMock has convertScopes parameter that if true, then Quarkus will change the scope of the target from Singleton bean to ApplicationScoped to make the mockable.

Also spy is supported:

+
metadata-builder-contributor
+
+

Class name of a custom org.hibernate.boot.spi.MetadataBuilderContributor implementation.

+
query.query-plan-cache-max-size

The maximum size of the query plan cache.

@@ -2691,6 +2833,18 @@

Charset.

+
scripts.generation
+
+

Select whether the database schema DDL files are generated or not. Possible values: none, create, drop-and-create, drop, update. (default: none)

+
+
scripts.generation.create-target
+
+

Filename or URL where the database create DDL file should be generated.

+
+
scripts.generation.drop-target
+
+

Filename or URL where the database drop DDL file should be generated.

+
jdbc.timezone

Time Zone JDBC driver.

@@ -3239,6 +3393,31 @@

+

Configuration properties prefixed with quarkus.hibernate-envers:

+
+
+
store-data-at-delete
+
+

Enable store_data_at_delete feature. (default: false)

+
+
audit-table-suffix
+
+

Defines a suffix for historical data table. (default: _AUD)

+
+
audit-table-prefix
+
+

Defines a prefix for historical data table. (default: ``)

+
+
revision-field-name
+
+

Revision field name. (default: REV)

+
+
revision-type-field-name
+
+

Revision type field name. (default: REVTYPE)

+
+
+
+

DevServices

+

When testing or running in dev mode Quarkus can even provide you with a zero config Infinispan out of the box.

+

Possible configuration values prefixed with quarkus.infinispan-client:

+
+
+
devservices.enabled
+
+

If devservices is enabled or not. (default: true)

+
+
devservices.port
+
+

Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly.

+
+
devservices.shared
+
+

Indicates if the Infinispan managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. (default: true)

+
+
devservices.service-name
+
+

The value of the quarkus-dev-service-infinispan label attached to the started container. (default: infinispan)

+
+
devservices.artifacts
+
+

List of the artifacts to automatically download and add to the Infinispan server libraries.

+
+
+
+

If you are using ElasticSearch in AWS you might need some extra config provided by an special extension https://quarkiverse.github.io/quarkiverse-docs/quarkus-hibernate-search-extras/dev/index.html

@@ -4721,6 +4970,18 @@

+

Testing

+

To start an embedded MongoDB database for your unit tests, Quarkus provides two QuarkusTestResourceLifecycleManager.

+

Add io.quarkus:quarkus-test-mongodb dependency.

+
+
+
// Single MongoDB instance
+@QuarkusTestResource(io.quarkus.test.mongodb.MongoTestResource.class)
+
+// ReplicaSet with two instances
+@QuarkusTestResource(io.quarkus.test.mongodb.MongoReplicaSetTestResource.class)
+
+

Multi MongoDB support

You can configure multiple MongoDB clients using same approach as with DataSource. The syntax is quarkus.mongodb.<optional name>.<property>:

@@ -4738,6 +4999,34 @@

+

DevServices

+

When testing or running in dev mode Quarkus can even provide you with a zero config MongoDB database out of the box.

+
+
+
%prod.quarkus.mongodb.connection-string=mongodb://localhost:27018
+
+
+

Possible configuration values prefixed with quarkus.datasource:

+
+
+
devservices.enabled
+
+

If devservices is enabled or not. (default: true)

+
+
devservices.image-name
+
+

The container image name to use instead of the default one.

+
+
devservices.port
+
+

Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly.

+
+
devservices.properties
+
+

Generic properties that are added to the database connection URL.

+
+
+

quarkus.mongodb as prefix is skipped in the following table.

@@ -4913,6 +5202,11 @@

Map<String, String>

+ + + + +

Authentication mechanism properties.

read-concern

String

Configures the read concern. Possible values: local, majority, linearizable, snapshot, available

@@ -5057,6 +5351,8 @@

+

Transsactions

+

To use them with MongoDB with Panache you need to annotate the method that starts the transaction with the @Transactional annotation.

Testing

To mock using active record pattern:

+

DevServices

+

When testing or running in dev mode Quarkus can even provide you with a zero config Kafka out of the box.

+

Possible configuration values prefixed with quarkus.kafka:

+
+
+
devservices.enabled
+
+

If devservices is enabled or not. (default: true)

+
+
devservices.image-name
+
+

The container image name to use instead of the default one. (default: docker.io/vectorized/redpanda:v21.5.5)

+
+
devservices.port
+
+

Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly.

+
+
devservices.shared
+
+

Indicates if the Kafka broker managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. (default: true)

+
+
devservices.service-name
+
+

The value of the quarkus-dev-service-kafka label attached to the started container. (default: kafka)

+
+
devservices.topic-partitions-timeout
+
+

Timeout for admin client calls used in topic creation. (default: 2S)

+
+
devservices.topic-partitions
+
+

The topic-partition pairs to create in the Dev Services Kafka broker. Example: quarkus.kafka.devservices.topic-partitions.test=2 will create a topic named test with 2 partitions

+
+
+
+

Apicurio Registry Avro

+

You can use Apicurio Registry Avro.

+
+
+
./mvnw quarkus:add-extension
+    -Dextensions="apicurio-registry-avro"
+
+
+

Place schemas at src/main/avro/ directory.

+
+
application.properties
+
+
mp.messaging.outgoing.movies.connector=smallrye-kafka
+mp.messaging.outgoing.movies.topic=movies
+
+# automatically register the schema with the registry, if not present
+mp.messaging.outgoing.movies.apicurio.registry.auto-register=true
+
+# URL of registry
+mp.messaging.connector.smallrye-kafka.schema.registry.url=http://localhost:8081
+
+
+

DevServices

+

When testing or running in dev mode Quarkus can even provide you with a zero config Apicurio Registry out of the box.

+

Possible configuration values prefixed with quarkus.apicurio-registry:

+
+
+
devservices.enabled
+
+

If devservices is enabled or not. (default: true)

+
+
devservices.image-name
+
+

The container image name to use instead of the default one. (default: docker.io/apicurio/apicurio-registry-mem:2.1.3.Final)

+
+
devservices.port
+
+

Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly.

+
+
devservices.shared
+
+

Indicates if the Apicurio managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. (default: true)

+
+
devservices.service-name
+
+

The value of the quarkus-dev-service-apicurio-registry label attached to the started container. (default: apicurio-registry)

+
+
+

AMQP

To integrate with AMQP you need to add next extensions:

@@ -5669,37 +6049,165 @@

<

A complete list of supported properties for AMQP.

-

MQTT

-

To integrate with MQTT you need to add next extensions:

+

DevServices

+

When testing or running in dev mode Quarkus can even provide you with a zero config AMQP out of the box.

+

Possible configuration values prefixed with quarkus.amqp:

+
+
+
devservices.enabled
+
+

If devservices is enabled or not. (default: true)

+
+
devservices.image-name
+
+

The container image name to use instead of the default one. (default: quay.io/artemiscloud/activemq-artemis-broker:0.1.2)

+
+
devservices.port
+
+

Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly.

+
+
devservices.extra-args
+
+

The value of the AMQ_EXTRA_ARGS environment variable to pass to the container. (default: --no-autotune --mapped --no-fsync)

+
+
devservices.shared
+
+

Indicates if the AMQP broker managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. (default: true)

+
+
devservices.service-name
+
+

The value of the quarkus-dev-service-aqmp label attached to the started container. (default: amqp)

+
+
+
+

RabbitMQ

+

To integrate with RabbitMQ you need to add next extensions:

./mvnw quarkus:add-extension
-    -Dextensions="vertx, smallrye-reactive-streams-operators
-        smallrye-reactive-messaging"
+ -Dextensions="smallrye-reactive-messaging-rabbitmq"
-

And add io.smallrye.reactive:smallrye-reactive-messaging-mqtt-1.0:0.0.10 dependency in your build tool.

Then @Outgoing, @Incoming or @Stream can be used.

-

MQTT configuration schema: mp.messaging.[outgoing|incoming].{stream-name}.<property>=<value>.

-

The connector type is smallrye-mqtt.

+

The connector type is smallrye-rabbitmq.

+

RabbitMQ configuration schema: mp.messaging.[outgoing|incoming].{stream-name}.<property>=<value>.

-
mp.messaging.outgoing.topic-price.type=
-    smallrye-mqtt
-mp.messaging.outgoing.topic-price.topic=
-    prices
-mp.messaging.outgoing.topic-price.host=
-    localhost
-mp.messaging.outgoing.topic-price.port=
-    1883
-mp.messaging.outgoing.topic-price.auto-generated-client-id=
-    true
+
mp.messaging.incoming.requests.connector=smallrye-rabbitmq
+mp.messaging.incoming.requests.queue.name=quote-requests
+mp.messaging.incoming.requests.exchange.name=quote-requests
 
-mp.messaging.incoming.prices.type=
-    smallrye-mqtt
-mp.messaging.incoming.prices.topic=
-    prices
-mp.messaging.incoming.prices.host=
+mp.messaging.outgoing.quotes.connector=smallrye-rabbitmq
+mp.messaging.outgoing.quotes.exchange.name=quotes
+
+
+

A complete list of supported properties for RabbitMQ.

+

DevServices

+

When testing or running in dev mode Quarkus can even provide you with a zero config RabbitMQ out of the box.

+

Possible configuration values prefixed with quarkus.rabbitmq:

+
+
+
devservices.enabled
+
+

If devservices is enabled or not. (default: true)

+
+
devservices.image-name
+
+

The container image name to use instead of the default one. (default: quay.io/kiegroup/kogito-data-index-ephemeral)

+
+
devservices.port
+
+

Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly.

+
+
devservices.shared
+
+

Indicates if the RabbitMQ managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. (default: true)

+
+
devservices.service-name
+
+

The value of the quarkus-dev-service-rabbitmq label attached to the started container. (default: rabbitmq)

+
+
devservices.exchanges.<exchanges>.type
+
+

Type of exchange: direct, topic, headers, fanout, etc. (default: direct)

+
+
devservices.exchanges.<exchanges>.auto-delete
+
+

Should the exchange be deleted when all queues are finished using it? (default: false)

+
+
devservices.exchanges.<exchanges>.durable
+
+

Should the exchange remain after restarts?

+
+
devservices.exchanges.<exchanges>.arguments
+
+

Extra arguments for the exchange definition.

+
+
devservices.queues.<queues>.auto-delete
+
+

Should the queue be deleted when all consumers are finished using it? (default: false)

+
+
devservices.queues.<queues>.durable
+
+

Should the queue remain after restarts? (default: false)

+
+
devservices.queues.<queues>.arguments
+
+

Extra arguments for the queue definition

+
+
devservices.bindings.<bindings>.source
+
+

Source exchange to bind to. Defaults to name of binding instance

+
+
devservices.bindings.<bindings>.routing-key
+
+

Routing key specification for the source exchange (default: #)

+
+
devservices.bindings.<bindings>.destination
+
+

Destination exchange or queue to bind to. Defaults to name of binding instance

+
+
devservices.bindings.<bindings>.destination-type
+
+

Destination type for binding: queue, exchange, etc. (default: queue)

+
+
devservices.bindings.<bindings>.arguments
+
+

Extra arguments for the binding definition

+
+
+
+

MQTT

+

To integrate with MQTT you need to add next extensions:

+
+
+
./mvnw quarkus:add-extension
+    -Dextensions="vertx, smallrye-reactive-streams-operators
+        smallrye-reactive-messaging"
+
+
+

And add io.smallrye.reactive:smallrye-reactive-messaging-mqtt-1.0:0.0.10 dependency in your build tool.

+

Then @Outgoing, @Incoming or @Stream can be used.

+

MQTT configuration schema: mp.messaging.[outgoing|incoming].{stream-name}.<property>=<value>.

+

The connector type is smallrye-mqtt.

+
+
+
mp.messaging.outgoing.topic-price.type=
+    smallrye-mqtt
+mp.messaging.outgoing.topic-price.topic=
+    prices
+mp.messaging.outgoing.topic-price.host=
+    localhost
+mp.messaging.outgoing.topic-price.port=
+    1883
+mp.messaging.outgoing.topic-price.auto-generated-client-id=
+    true
+
+mp.messaging.incoming.prices.type=
+    smallrye-mqtt
+mp.messaging.incoming.prices.topic=
+    prices
+mp.messaging.incoming.prices.host=
     localhost
 mp.messaging.incoming.prices.port=
     1883
@@ -5707,7 +6215,6 @@ 

< true

-
@@ -5796,6 +6303,11 @@

+ +

Testing

+

You can use @TestSecurity annotation tooin OIDC by registering the following dependency:

+
+
+
<dependency>
+    <groupId>io.quarkus</groupId>
+    <artifactId>quarkus-test-security-jwt</artifactId>
+    <scope>test</scope>
+</dependency>
+
+
+
+
+
@Test
+@TestSecurity(user = "userJwt", roles = "viewer")
+@JwtSecurity(claims = {
+    @Claim(key = "email", value = "user@gmail.com")
+})
+public void testJwtWithClaims() {}
+
+

Generate tokens

JWT generation API:

+

You can inject the folowing Oidc objects in a class:

+
+
+
@Inject
+io.quarkus.oidc.UserInfo userInfo;
+
+@Inject
+io.quarkus.oidc.OidcConfigurationMetadata configMetadata;
+
+

Configure application to Keycloak service in application.properties file.

+

quarkus-oidc-client can be configured as follows to support MTLS:

+
+
+
quarkus.oidc.tls.verification=certificate-validation
+
+quarkus.oidc.client.tls.key-store-file=client-keystore.jks
+quarkus.oidc.client.tls.key-store-password=${key-store-password}
+
+quarkus.oidc.client.tls.key-store-alias=keyAlias
+quarkus.oidc.client.tls.key-store-alias-password=keyAliasPassword
+
+quarkus.oidc.client.tls.trust-store-file=client-truststore.jks
+quarkus.oidc.client.tls.trust-store-password=${trust-store-password}
+
+quarkus.oidc.client.tls.trust-store-alias=certAlias
+
+
+

There is also support for the public OIDC providers:

+

GitHub

+
+
+
quarkus.oidc.provider=github
+quarkus.oidc.client-id=github_app_clientid
+quarkus.oidc.credentials.secret=github_app_clientsecret
+
+
+

Apple

+
+
+
quarkus.oidc.provider=apple
+quarkus.oidc.client-id=${apple.client-id}
+quarkus.oidc.credentials.jwt.token-key-id=${apple.key-id}
+
+
+

Google

+
+
+
quarkus.oidc.provider=google
+quarkus.oidc.client-id={GOOGLE_CLIENT_ID}
+quarkus.oidc.credentials.secret={GOOGLE_CLIENT_SECRET}
+quarkus.oidc.token.issuer=https://accounts.google.com
+
+

Configuration options with quarkus.oidc prefix:

+

Testing

+

You can use @TestSecurity annotation tooin OIDC by registering the following dependency:

+
+
+
<dependency>
+    <groupId>io.quarkus</groupId>
+    <artifactId>quarkus-test-security-oidc</artifactId>
+    <scope>test</scope>
+</dependency>
+
+
+
+
+
@Test
+@TestSecurity(user = "userOidc", roles = "viewer")
+@OidcSecurity(claims = {
+        @Claim(key = "email", value = "user@gmail.com")
+}, userinfo = {
+        @UserInfo(key = "sub", value = "subject")
+}, config = {
+        @ConfigMetadata(key = "issuer", value = "issuer")
+})
+public void testOidcWithClaimsUserInfoAndMetadata() {}
+
+
+

DevServices

+

When testing or running in dev mode Quarkus can even provide you with a zero config Keycloak out of the box.

+

Possible configuration values prefixed with quarkus.keycloak:

+
+
+
devservices.enabled
+
+

If devservices is enabled or not. (default: true)

+
+
devservices.image-name
+
+

The container image name to use instead of the default one. Keycloak-X can be used (quay.io/keycloak/keycloak-x:15.0.2) (default: quay.io/keycloak/keycloak:15.0.2)

+
+
devservices.keycloak-x-image
+
+

Set quarkus.devservices.keycloak.keycloak-x-image to override this check which may be necessary if you build custom Keycloak-X or Keycloak images. You do not need to set this property if the default check works.

+
+
devservices.port
+
+

Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly.

+
+
devservices.shared
+
+

Indicates if the Keycloak broker managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. (default: true)

+
+
devservices.service-name
+
+

The value of the quarkus-dev-service-keycloak label attached to the started container. (default: kafka)

+
+
devservices.realm-path
+
+

The class or file system path to a Keycloak realm file which will be used to initialize Keycloak

+
+
devservices.java-opts
+
+

The JAVA_OPTS passed to the keycloak JVM

+
+
devservices.realm-name
+
+

The Keycloak realm name

+
+
devservices.create-realm
+
+

Indicates if the Keycloak realm has to be created when the realm file pointed to by the 'realm-path' property does not exist

+
+
devservices.users
+
+

The Keycloak users map containing the user name and password pairs

+
+
devservices.roles
+
+

The Keycloak user roles

+
+
+

Multi-tenancy

Multi-tenancy is supported by adding a sub-category to OIDC configuration properties (ie quarkus.oidc.{tenent_id}.property).

+

You can inject io.quarkus.oidc.client.Tokens, io.quarkus.oidc.OidcSession, and io.quarkus.oidc.client.OidcClient to interact with OIDC.

+
+
+
@Inject
+@io.quarkus.oidc.client.NamedOidcClient("client2")
+OidcClient client;
+
+@Inject
+@io.quarkus.oidc.client.NamedOidcClient("client1")
+Tokens tokens1;
+
+@Inject
+OidcSession oidcSession;
+
+
-
@@ -7530,13 +8224,17 @@

< Using quarkus.http prefix:

+
http.access-log.exclude-pattern
+
+

A regular expression that can be used to exclude some paths from logging

+
cors

Enable CORS. (default: false)

cors.origins
-

CSV of origins allowed. (dedault: Any request valid.)

+

CSV of origins allowed. Regular expressions are also allowed (dedault: Any request valid.)

cors.methods
@@ -7572,40 +8270,52 @@

<

test-ssl-port
-

The HTTPS port used to run tests. (default 8444)

+

The HTTPS port used to run tests. (default: 8444)

-
proxy-address-forwarding
+
insecure-requests
+
+

If insecure requests are allowed. Possible values: enabled, redirect, disable. (default: enabled)

+
+
http2
+
+

Enables HTTP/2. (default: true)

+
+
proxy.proxy-address-forwarding

The address, scheme etc will be set from headers forwarded by the proxy server.

-
allow-forwarded
+
proxy.allow-forwarded

Proxy address forwarding is enabled then the standard Forwarded header will be used, rather than the more common but not standard X-Forwarded-For.

-
insecure-requests
+
proxy.enable-forwarded-host
-

If insecure requests are allowed. Possible values: enabled, redirect, disable. (default: enabled)

+

Enable override the received request’s host through a forwarded host header

-
http2
+
proxy.forwarded-host-header
-

Enables HTTP/2. (default: true)

+

Configure the forwarded host header to be used if override enabled

ssl.port

The HTTPS port. (default: 8443)

-
ssl.certificate.file
+
ssl.certificate.files
-

The file path to a service certificate or certificate chain in PEM format. Relative to src/main/resources.

+

The files path to a service certificate or certificate chain in PEM format. Relative to src/main/resources.

-
ssl.certificate.key-file
+
ssl.certificate.key-files
-

The file path to the corresponding certificate private key in PEM format. Relative to src/main/resources.

+

The files path to the corresponding certificate private key in PEM format. Relative to src/main/resources.

ssl.certificate.key-store-file

The key store contains the certificate information. Relative to src/main/resources.

+
ssl.certificate.key-store-key-alias
+
+

An optional parameter to select a specific key in the key store.

+
ssl.certificate.key-store-file-type

The key store type. It is automatically detected based on the file name or can be set manually. Supported values are: JKS, JCEKS, P12, PKCS12 or PFX.

@@ -7614,12 +8324,14 @@

<

The password to open the key store file.

-

-
-

ssl.certificate.trust-store-file -The trust store location which contains the certificate information of the certificates to trust. Relative to src/main/resources.

-
-
+
ssl.certificate.trust-store-file
+
+

The trust store location which contains the certificate information of the certificates to trust. Relative to src/main/resources.

+
+
ssl.certificate.trust-store-cert-alias
+
+

An optional parameter to trust only one specific certificate in the trust store

+
ssl.certificate.trust-store-file-type

The trust store type. It is automatically detected based on the file name or can be set manually.

@@ -7636,6 +8348,10 @@

<

The list of protocols to explicitly enable. (default: TLSv1.3 and TLSv1.2).

+
ssl.sni
+
+

Enables Server Name Indication (SNI), an TLS extension allowing the server to use multiple certificates. (default: false)

+
ssl.client-auth

Configures the engine to require/request client authentication. Possible values are: none, request and required. (default: none).

@@ -8080,12 +8796,68 @@

schema-available +
+

Make the schema available over HTTP. (default: true)

+
metrics.enabled

Enable metrics. (default: false)

+

GraphQL Clients

+
+
+
./mvnw quarkus:add-extension
+  -Dextensions="graphql-client"
+
+
+
+
+
quarkus.smallrye-graphql-client.star-wars.url=https://swapi-graphql.netlify.app/.netlify/functions/index
+
+
+

Typesafe client

+
+
+
@GraphQLClientApi(configKey = "star-wars")
+public interface StarWarsClientApi {
+
+    FilmConnection allFilms();
+
+}
+
+@Inject
+StarWarsClientApi typesafeClient;
+
+
+

allFilms is also the name of the query. +You can override the value using @Query(value="allStarWarsFilms")

+

Dynamic client

+
+
+
@Inject
+@GraphQLClient("star-wars")
+DynamicGraphQLClient dynamicClient;
+
+Document query = document(
+        operation(
+            field("allFilms",
+                field("films",
+                    field("title"),
+                    field("planetConnection",
+                        field("planets",
+                            field("name")
+                        )
+                    )
+                )
+            )
+        )
+    );
+Response response = dynamicClient.executeSync(query)
+
+

To consume the service:

-
@GrpcService("hello")
+
@GrpcClient("hello")
 GreeterGrpc.GreeterBlockingStub client;
 
-@GrpcService("hello")
-io.grpc.Channel channel;
+@GrpcClient("hello") +io.grpc.Channel channel; + +// Adding headers + +Metadata extraHeaders = new Metadata(); +extraHeaders.put("my-header", "my-interface-value"); + +GreeterBlockingStub alteredClient = io.quarkus.grpc.GrpcClientUtils.attachHeaders(client, extraHeaders);
+
+
+

Interceptors

+
+
+
import io.quarkus.grpc.GlobalInterceptor;
+import io.grpc.ClientInterceptor;
+
+@GlobalInterceptor
+@ApplicationScoped
+public class MyInterceptor implements ClientInterceptor {}
+
+@RegisterClientInterceptor(MySpecialInterceptor.class) (1)
+@GrpcClient("helloService")
+Greeter greeter;

Some configuration example to set the host and the SSL parameters:

@@ -8266,6 +9064,91 @@

+

Smallrye Stork

+
+

Stork implements client load-balancing strategies supporting Kubernetes, and Consul.

+

Consul

+

Add following dependencies:

+
+
+
<dependency>
+  <groupId>io.smallrye.stork</groupId>
+  <artifactId>stork-service-discovery-consul</artifactId>
+</dependency>
+<dependency>
+  <groupId>io.smallrye.reactive</groupId>
+  <artifactId>smallrye-mutiny-vertx-consul-client</artifactId>
+</dependency>
+
+
+

Register service instances to Consul:

+
+
+
@ApplicationScoped
+public class Registration {
+
+    @ConfigProperty(name = "consul.host") String host;
+    @ConfigProperty(name = "consul.port") int port;
+
+    public void init(@Observes StartupEvent ev, Vertx vertx) {
+        ConsulClient client = ConsulClient.create(vertx,
+                                new ConsulClientOptions().setHost(host).setPort(port));
+
+        client.registerServiceAndAwait(
+                new ServiceOptions().setPort(8080)
+                    .setAddress("host1").setName("my-service").setId("blue"));
+        client.registerServiceAndAwait(
+                new ServiceOptions().setPort(8080)
+                    .setAddress("host2").setName("my-service").setId("red"));
+
+    }
+}
+
+
+

Configuration:

+
+
+
consul.host=localhost
+consul.port=8500
+
+stork.my-service.service-discovery=consul
+stork.my-service.service-discovery.consul-host=localhost
+stork.my-service.service-discovery.consul-port=8500
+stork.my-service.load-balancer=round-robin
+
+
+

Kubernetes

+

Add following dependencies:

+
+
+
<dependency>
+  <groupId>io.smallrye.reactive</groupId>
+  <artifactId>stork-service-discovery-kubernetes</artifactId>
+</dependency>
+
+
+
+
+
stork.my-service.service-discovery=kubernetes
+stork.my-service.service-discovery.k8s-namespace=my-namespace
+stork.my-service.load-balancer=round-robin
+
+
+

Using Stork at client

+
+
+
@RegisterRestClient(baseUri = "stork://my-service")
+public interface MyService {
+
+    @GET
+    @Produces(MediaType.TEXT_PLAIN)
+    String get();
+}
+
+
+
+
+

Fault Tolerance

Quarkus uses MicroProfile Fault Tolerance spec:

@@ -8338,6 +9221,19 @@

+

From smallrye project Fibonacci and Exponential Backoff retries annotations are provided:

+
+
+
public class TwoBackoffsOnMethodService {
+    @Retry
+    @io.smallrye.faulttolerance.api.ExponentialBackoff
+    @io.smallrye.faulttolerance.api.FibonacciBackoff
+    public void hello() {
+        throw new IllegalArgumentException();
+    }
+}
+
+

Fault tolerance annotations:

@@ -8574,7 +9470,10 @@

You can disable the automatic generation by setting <component>.health.enabled to false.

+

MicroProfile Health currently doesn’t support returning reactive types, but SmallRye Health does. +Implement the io.smallrye.health.api.AsyncHealthCheck interface instead of the org.eclipse.microprofile.health.HealthCheck.

+
+
+
@Liveness
+@ApplicationScoped
+public class LivenessAsync implements AsyncHealthCheck {
+    @Override
+    public Uni<HealthCheckResponse> call() {
+        return Uni.createFrom().item(HealthCheckResponse.up("liveness-reactive"))
+                .onItem().delayIt().by(Duration.ofMillis(10));
+    }
+}
+
+

Metrics

Quarkus can utilize the MicroProfile Metrics spec to provide metrics support.

@@ -8899,8 +9813,99 @@

OpenTelemetry

-

Quarkus integrates with the OpenTelemetry project. -For exporting traces to a Jaeger collector, use the quarkus-opentelemetry-exporter-jaeger extension.

+
+
+
./mvnw quarkus:add-extension
+    -Dextensions="opentelemetry-otlp-exporter"
+
+
+

Possible configuration:

+
+
+
quarkus.application.name=myservice
+quarkus.opentelemetry.enabled=true
+quarkus.opentelemetry.tracer.exporter.otlp.endpoint=http://localhost:4317
+
+quarkus.opentelemetry.tracer.exporter.otlp.headers=Authorization=Bearer my_secret
+
+
+

The OpenTelemetry extension enables the W3C Trace Context and the W3C Baggage propagators, you can however choose any of the supported OpenTelemetry propagators.

+

The b3, b3multi, jaeger and ottrace propagators:

+
+
+
<dependency>
+    <groupId>io.opentelemetry</groupId>
+    <artifactId>opentelemetry-extension-trace-propagators</artifactId>
+</dependency>
+
+
+

The xray propagator:

+
+
+
<dependency>
+    <groupId>io.opentelemetry</groupId>
+    <artifactId>opentelemetry-extension-aws</artifactId>
+</dependency>
+
+
+

You can configure OpenTelemetry. +Prefix is quarkus.opentelemetry:

+
+
+
enabled
+
+

OpenTelemetry support (default: true)

+
+
propagators
+
+

Comma separated list of OpenTelemetry propagators which must be supported. Possible values b3, b3multi, baggage, jaeger, ottrace, tracecontext, xray (default: traceContext,baggage).

+
+
tracer.enabled
+
+

Support for tracing with OpenTelemetry.

+
+
tracer.resource-attributes
+
+

A comma separated list of name=value resource attributes that represents the entity producing telemetry

+
+
tracer.sampler
+
+

The sampler to use for tracing. Possible values off, on, ratio. (Default: on)

+
+
tracer.sampler.ratio
+
+

Ratio to sample

+
+
tracer.sampler.parent-based
+
+

If the sampler to use for tracing is parent based (default: true)

+
+
tracer.suppress-non-application-uris
+
+

Suppress non-application uris from trace collection. (default: true)

+
+
tracer.exporter.otlp.enabled
+
+

OTLP SpanExporter support (default: true)

+
+
tracer.exporter.otlp.endpoint
+
+

The OTLP endpoint to connect to

+
+
tracer.exporter.otlp.headers
+
+

Key-value pairs to be used as headers associated with gRPC requests

+
+
tracer.exporter.otlp.export-timeout
+
+

The maximum amount of time to wait for the collector to process exported spans before an exception is thrown. (default: 10S)

+
+
tracer.exporter.otlp.compression
+
+

Compression method to be used by exporter to compress the payload

+
+
+

Kafka Tracer

Adds a span for each message sent to or received from a Kafka topic.

To configure native application, you can create a config directory at the same place as the native file and place an application.properties file inside. config/application.properties.

+

To produce a native executable with native excutable use -Dquarkus.native.additional-build-args=-J—​enable-preview.

SSL

To create a native image with SSL you need to copy SunEC library and certificates:

Java 8:

@@ -9202,6 +10208,10 @@

labels +
+

Custom labels to add to the generated image.

+

Jib

@@ -9247,9 +10257,9 @@

labels +
offline-mode
-

Custom labels to add to the generated image.

+

Whether or not to operate offline. (default: false)

base-registry-username
@@ -9279,6 +10289,10 @@

docker-executable-ame +
+

Name of binary used to execute the docker commands.

+

Docker

@@ -9301,6 +10315,54 @@

Buildpacks

+
+
+
./mvnw quarkus:add-extensions
+    -Dextensions="quarkus-container-image-buildpack"
+
+
+

Prefix is quarkus.buildpack:

+
+
+
jvm-builder-image
+
+

The buildpacks builder image to use when building the project in jvm mode.

+
+
native-builder-image
+
+

The buildpacks builder image to use when building the project in native mode.

+
+
builder-env
+
+

Environment key/values to pass to buildpacks.

+
+
run-image
+
+

The buildpacks run image to use when building the project.

+
+
pull-timeout-seconds
+
+

Max pull timeout for builder/run images, in seconds (default: 300)

+
+
docker-host
+
+

DOCKER_HOST value to use.

+
+
log-level
+
+

Log level to use. (default info)

+
+
base-registry-username
+
+

The username to use to authenticate with the registry used to pull the base image.

+
+
base-registry-password
+
+

The password to use to authenticate with the registry used to pull the base image.

+
+
+

S2I

-

Datasource configuration part is absent as it is aut-discovered by Quarkus.

+

Datasource configuration part is absent as it is auto-discovered by Quarkus.

+

If you only want the client you can include quarkus-websockets-client.

And web sockets classes can be used:

@@ -10208,54 +11274,110 @@

Possible OpenAPI options with quarkus.smallrye-openapi prefix:

-
path
+
path

The path at which to register the OpenAPI Servlet. (default: openapi)

-
store-schema-directory
+
store-schema-directory

The generated OpenAPI schema documents will be stored here on build.

-
security-scheme
+
always-run-filter
+
+

Do not run the filter only at startup, but every time the document is requested (dynamic). (default: false)

+
+
ignore-static-document
+
+

Do not include the provided static openapi document. (default: false)

+
+
additional-docs-directory
+
+

A list of local directories that should be scanned for yaml and/or json files to be included in the static model.

+
+
security-scheme

Add a certain SecurityScheme with config. (basic, jwt, oidc, oauth2Implicit)

-
security-scheme-name
+
security-scheme-name

Add a Security Scheme name to the generated OpenAPI document. (default: SecurityScheme)

-
security-scheme-description
+
security-scheme-description

Add a description to the Security Scheme. (default: Authentication)

-
basic-security-scheme-value
+
basic-security-scheme-value

Add a scheme value to the Basic HTTP Security Scheme. (default: basic)

-
jwt-security-scheme-value
+
jwt-security-scheme-value

Add a scheme value to the JWT Security Scheme. (default: bearer)

-
jwt-bearer-format
+
jwt-bearer-format

Add a bearer format to the JWT Security Scheme. (default: JWT)

-
oidc-open-id-connect-url
+
oidc-open-id-connect-url

Add a openIdConnectUrl value to the OIDC Security Scheme

-
oauth2-implicit-refresh-url
+
oauth2-implicit-refresh-url

Add a implicit flow refreshUrl value to the OAuth2 Security Scheme

-
oauth2-implicit-authorization-url
+
oauth2-implicit-authorization-url

Add an implicit flow authorizationUrl value to the OAuth2 Security Scheme

-
oauth2-implicit-token-url
+
oauth2-implicit-token-url

Add an implicit flow tokenUrl value to the OAuth2 Security Scheme

+
open-api-version
+
+

Override the openapi version in the Schema document

+
+
info-title
+
+

Set the title in Info tag in the Schema document

+
+
info-version
+
+

Set the version in Info tag in the Schema document

+
+
info-description
+
+

Set the description in Info tag in the Schema document

+
+
info-terms-of-service
+
+

Set the terms of the service in Info tag in the Schema document

+
+
info-contact-email
+
+

Set the contact email in Info tag in the Schema document

+
+
info-contact-name
+
+

Set the contact name in Info tag in the Schema document

+
+
info-contact-url
+
+

Set the contact url in Info tag in the Schema document

+
+
info-license-name
+
+

Set the license name in Info tag in the Schema document

+
+
info-license-url
+
+

Set the license url in Info tag in the Schema document

+
+
operation-id-strategy
+
+

Set the strategy to automatically create an operation Id. Possible values: method,class-method, package-class-method

+

@@ -10501,14 +11623,19 @@

every and cron parameters can be surrounded with {} and the value is used as config property to get the value.

-
@Scheduled(cron = "{morning.check.cron.expr}")
-void morningTask() {}
+
@Scheduled(cron = "${morning.check.cron.expr}")
+void morningTask() {}
+
+@Scheduled(cron = "${myMethod.cron.expr:0 0 15 ? * MON *}")
+void myMethod() {}

And configure the property into application.properties:

-
morning.check.cron.expr=0 15 10 * * ?
+
morning.check.cron.expr=0 15 10 * * ?
+
+morning.check.cron.expr=disabled

By default Quarkus expresion is used, but you can change that by setting quarkus.scheduler.cron-type property.

@@ -10526,6 +11653,20 @@

+

Quarkus provides a built-in bean of type io.quarkus.scheduler.Scheduler:

+
+
+
@Inject
+io.quarkus.scheduler.Scheduler scheduler;
+
+
+scheduler.pause(); // Pause all
+scheduler.pause("myIdentity"); // Pause a specific scheduled method by its identity
+
+scheduler.resume("myIdentity");
+scheduler.resume()
+
+
+

DevServices

+

When testing or running in dev mode Quarkus can even provide you with a zero config Kogito out of the box.

+

Possible configuration values prefixed with quarkus.kogito:

+
+
+
devservices.enabled
+
+

If devservices is enabled or not. (default: true)

+
+
devservices.image-name
+
+

The container image name to use instead of the default one. (default: quay.io/kiegroup/kogito-data-index-ephemeral)

+
+
devservices.port
+
+

Optional fixed port the dev service will listen to. (default: 8180)

+
+
devservices.shared
+
+

Indicates if the Data Index instance managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. (default: true)

+
+
devservices.service-name
+
+

The value of the kogito-dev-service-data-index label attached to the started container. (default: kogito-data-index)

+
+
+

Following operators can be used either in when and switch: not, ne, !=, gt, >, ge, >=, lt, <, le, <=, in, ni, !in.

+

eval

+
+
+
{#eval myData.template name='Mia' /}
+
+
+

The result of myData.template will be used as the template.

Message Bundling

+ + +
+

Narayana LRA

+
+

The LRA (short for Long Running Action) participant extension is useful in microservice based designs where different services can benefit from a relaxed notion of distributed consistency.

+

The extension integrates with MicroProfile LRA

+
+
+
./mvnw quarkus:add-extension
+  -Dextensions="narayana-lra"
+
+
+

The only LRA specific property is quarkus.lra.coordinator-url=<url> which specifies the HTTP endpoint of an external coordinator,

+
+
+
@Path("/")
+@ApplicationScoped
+public class SimpleLRAParticipant
+{
+  @LRA(LRA.Type.REQUIRES_NEW)
+  @Path("/work")
+  @PUT
+  public void doInNewLongRunningAction(@HeaderParam(LRA_HTTP_CONTEXT_HEADER) URI lraId)
+  {
+  }
+
+  @org.eclipse.microprofile.lra.annotation.Complete
+  @Path("/complete")
+  @PUT
+  public Response completeWork(@HeaderParam(LRA_HTTP_CONTEXT_HEADER) URI lraId,
+                                 String userData)
+  {
+    return Response.ok(ParticipantStatus.Completed.name()).build();
+  }
+
+  @org.eclipse.microprofile.lra.annotation.Compensate
+  @Path("/compensate")
+  @PUT
+  public Response compensateWork(@HeaderParam(LRA_HTTP_CONTEXT_HEADER) URI lraId,
+                                   String userData)
+  {
+    return Response.ok(ParticipantStatus.Compensated.name()).build();
+  }
+}
+
+
+

@LRA can be used in differrent methods, so it’s started in one method and finished in another resource using end attribute:

+
+
+
@LRA(value = LRA.Type.REQUIRED, // if there is no incoming context a new one is created
+      cancelOn = {
+        Response.Status.INTERNAL_SERVER_ERROR // cancel on a 500 code
+      },
+      cancelOnFamily = {
+        Response.Status.Family.CLIENT_ERROR // cancel on any 4xx code
+      },
+    end = false) // the LRA will continue to run when the method finishes
+
+@LRA(LRA.Type.MANDATORY, // requires an active context before method can be executed
+      end = true)
+
+
@@ -11811,7 +13070,7 @@

-If you scaffold the project with spring-web extension, then Spring Web annotations are sed in the generated project. mvn io.quarkus:quarkus-maven-plugin:1.13.0.Final:create …​ -Dextensions="spring-web". +If you scaffold the project with spring-web extension, then Spring Web annotations are sed in the generated project. mvn io.quarkus:quarkus-maven-plugin:2.7.0.Final:create …​ -Dextensions="spring-web".
@@ -12145,7 +13404,7 @@

Authors :

Java Champion and Director of DevExp at Red Hat
-
1.13.0.Final
+
2.7.0.Final
diff --git a/examples/quarkus-cheat-sheet/quarkus-cheat-sheet.pdf b/examples/quarkus-cheat-sheet/quarkus-cheat-sheet.pdf index 18aed052..0ace3f0a 100644 Binary files a/examples/quarkus-cheat-sheet/quarkus-cheat-sheet.pdf and b/examples/quarkus-cheat-sheet/quarkus-cheat-sheet.pdf differ diff --git a/examples/quarkus-cheat-sheet/reactive.adoc b/examples/quarkus-cheat-sheet/reactive.adoc index a65a9d8c..8ba8facf 100644 --- a/examples/quarkus-cheat-sheet/reactive.adoc +++ b/examples/quarkus-cheat-sheet/reactive.adoc @@ -448,6 +448,79 @@ public class BeerDeserializer } ---- +_DevServices_ + +When testing or running in dev mode Quarkus can even provide you with a zero config Kafka out of the box. + +Possible configuration values prefixed with `quarkus.kafka`: + +`devservices.enabled`:: +If devservices is enabled or not. (default: `true`) + +`devservices.image-name`:: +The container image name to use instead of the default one. (default: `docker.io/vectorized/redpanda:v21.5.5`) + +`devservices.port`:: +Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly. + +`devservices.shared`:: +Indicates if the Kafka broker managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. (default: `true`) + +`devservices.service-name`:: +The value of the `quarkus-dev-service-kafka` label attached to the started container. (default: `kafka`) + +`devservices.topic-partitions-timeout`:: +Timeout for admin client calls used in topic creation. (default: `2S`) + +`devservices.topic-partitions`:: +The topic-partition pairs to create in the Dev Services Kafka broker. Example: `quarkus.kafka.devservices.topic-partitions.test=2` will create a topic named test with 2 partitions + +*Apicurio Registry Avro* + +You can use Apicurio Registry Avro. + +[source, bash] +---- +./mvnw quarkus:add-extension + -Dextensions="apicurio-registry-avro" +---- + +Place schemas at `src/main/avro/` directory. + +[source, properties] +.application.properties +---- +mp.messaging.outgoing.movies.connector=smallrye-kafka +mp.messaging.outgoing.movies.topic=movies + +# automatically register the schema with the registry, if not present +mp.messaging.outgoing.movies.apicurio.registry.auto-register=true + +# URL of registry +mp.messaging.connector.smallrye-kafka.schema.registry.url=http://localhost:8081 +---- + +_DevServices_ + +When testing or running in dev mode Quarkus can even provide you with a zero config Apicurio Registry out of the box. + +Possible configuration values prefixed with `quarkus.apicurio-registry`: + +`devservices.enabled`:: +If devservices is enabled or not. (default: `true`) + +`devservices.image-name`:: +The container image name to use instead of the default one. (default: `docker.io/apicurio/apicurio-registry-mem:2.1.3.Final`) + +`devservices.port`:: +Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly. + +`devservices.shared`:: +Indicates if the Apicurio managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. (default: `true`) + +`devservices.service-name`:: +The value of the `quarkus-dev-service-apicurio-registry` label attached to the started container. (default: `apicurio-registry`) + *AMQP* To integrate with AMQP you need to add next extensions: @@ -485,6 +558,115 @@ mp.messaging.incoming.prices.durable= A complete list of supported properties for https://smallrye.io/smallrye-reactive-messaging/#_interacting_using_amqp[AMQP, window="_blank"]. +_DevServices_ + +When testing or running in dev mode Quarkus can even provide you with a zero config AMQP out of the box. + +Possible configuration values prefixed with `quarkus.amqp`: + +`devservices.enabled`:: +If devservices is enabled or not. (default: `true`) + +`devservices.image-name`:: +The container image name to use instead of the default one. (default: `quay.io/artemiscloud/activemq-artemis-broker:0.1.2`) + +`devservices.port`:: +Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly. + +`devservices.extra-args`:: +The value of the `AMQ_EXTRA_ARGS` environment variable to pass to the container. (default: `--no-autotune --mapped --no-fsync`) + +`devservices.shared`:: +Indicates if the AMQP broker managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. (default: `true`) + +`devservices.service-name`:: +The value of the `quarkus-dev-service-aqmp` label attached to the started container. (default: `amqp`) + +*RabbitMQ* + +To integrate with RabbitMQ you need to add next extensions: + +[source, bash] +---- +./mvnw quarkus:add-extension + -Dextensions="smallrye-reactive-messaging-rabbitmq" +---- + +Then `@Outgoing`, `@Incoming` or `@Stream` can be used. + +The connector type is `smallrye-rabbitmq`. + +RabbitMQ configuration schema: `mp.messaging.[outgoing|incoming].\{stream-name\}.=`. + +[source, properties] +---- +mp.messaging.incoming.requests.connector=smallrye-rabbitmq +mp.messaging.incoming.requests.queue.name=quote-requests +mp.messaging.incoming.requests.exchange.name=quote-requests + +mp.messaging.outgoing.quotes.connector=smallrye-rabbitmq +mp.messaging.outgoing.quotes.exchange.name=quotes +---- + +A complete list of supported properties for https://quarkus.io/guides/rabbitmq-reference[RabbitMQ, window="_blank"]. + +_DevServices_ + +When testing or running in dev mode Quarkus can even provide you with a zero config RabbitMQ out of the box. + +Possible configuration values prefixed with `quarkus.rabbitmq`: + +`devservices.enabled`:: +If devservices is enabled or not. (default: `true`) + +`devservices.image-name`:: +The container image name to use instead of the default one. (default: `quay.io/kiegroup/kogito-data-index-ephemeral`) + +`devservices.port`:: +Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly. + +`devservices.shared`:: +Indicates if the RabbitMQ managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. (default: `true`) + +`devservices.service-name`:: +The value of the `quarkus-dev-service-rabbitmq` label attached to the started container. (default: `rabbitmq`) + +`devservices.exchanges..type`:: +Type of exchange: `direct`, `topic`, `headers`, `fanout`, etc. (default: `direct`) + +`devservices.exchanges..auto-delete`:: +Should the exchange be deleted when all queues are finished using it? (default: `false`) + +`devservices.exchanges..durable`:: +Should the exchange remain after restarts? + +`devservices.exchanges..arguments`:: +Extra arguments for the exchange definition. + +`devservices.queues..auto-delete`:: +Should the queue be deleted when all consumers are finished using it? (default: `false`) + +`devservices.queues..durable`:: +Should the queue remain after restarts? (default: `false`) + +`devservices.queues..arguments`:: +Extra arguments for the queue definition + +`devservices.bindings..source`:: +Source exchange to bind to. Defaults to name of binding instance + +`devservices.bindings..routing-key`:: +Routing key specification for the source exchange (default: `#`) + +`devservices.bindings..destination`:: +Destination exchange or queue to bind to. Defaults to name of binding instance + +`devservices.bindings..destination-type`:: +Destination type for binding: queue, exchange, etc. (default: `queue`) + +`devservices.bindings..arguments`:: +Extra arguments for the binding definition + *MQTT* To integrate with MQTT you need to add next extensions: @@ -531,8 +713,6 @@ mp.messaging.incoming.prices.auto-generated-client-id= // end::update_3_8[] // end::update_1_4[] -<<< - == Kafka Streams // tag::update_3_10[] @@ -620,6 +800,8 @@ Trust configuration in the PEM format. `reactive.trust-certificate-jks`:: Trust configuration in the JKS format. +<<< + `reactive.trust-certificate-pfx`:: Trust configuration in the PFX format. diff --git a/examples/quarkus-cheat-sheet/security.adoc b/examples/quarkus-cheat-sheet/security.adoc index c64dcd5b..3400e30b 100644 --- a/examples/quarkus-cheat-sheet/security.adoc +++ b/examples/quarkus-cheat-sheet/security.adoc @@ -261,6 +261,29 @@ JWT `groups` claim is directly mapped to roles to be used in security annotation ---- // end::update_1_5[] +*Testing* + +You can use `@TestSecurity` annotation tooin OIDC by registering the following dependency: + +[source, xml] +---- + + io.quarkus + quarkus-test-security-jwt + test + +---- + +[source, java] +---- +@Test +@TestSecurity(user = "userJwt", roles = "viewer") +@JwtSecurity(claims = { + @Claim(key = "email", value = "user@gmail.com") +}) +public void testJwtWithClaims() {} +---- + *Generate tokens* // tag::update_13_15[] @@ -314,6 +337,17 @@ You can also protect resources with security annotations. @RolesAllowed("admin") ---- +You can inject the folowing Oidc objects in a class: + +[source, java] +---- +@Inject +io.quarkus.oidc.UserInfo userInfo; + +@Inject +io.quarkus.oidc.OidcConfigurationMetadata configMetadata; +---- + Configure application to Keycloak service in `application.properties` file. [source, properties] @@ -325,6 +359,54 @@ quarkus.oidc.bearer-only=true quarkus.oidc.credentials.secret=secret ---- +`quarkus-oidc-client` can be configured as follows to support `MTLS`: + +[source,properties] +---- +quarkus.oidc.tls.verification=certificate-validation + +quarkus.oidc.client.tls.key-store-file=client-keystore.jks +quarkus.oidc.client.tls.key-store-password=${key-store-password} + +quarkus.oidc.client.tls.key-store-alias=keyAlias +quarkus.oidc.client.tls.key-store-alias-password=keyAliasPassword + +quarkus.oidc.client.tls.trust-store-file=client-truststore.jks +quarkus.oidc.client.tls.trust-store-password=${trust-store-password} + +quarkus.oidc.client.tls.trust-store-alias=certAlias +---- + +There is also support for the public OIDC providers: + +*GitHub* + +[source, properties] +---- +quarkus.oidc.provider=github +quarkus.oidc.client-id=github_app_clientid +quarkus.oidc.credentials.secret=github_app_clientsecret +---- + +*Apple* + +[source, properties] +---- +quarkus.oidc.provider=apple +quarkus.oidc.client-id=${apple.client-id} +quarkus.oidc.credentials.jwt.token-key-id=${apple.key-id} +---- + +*Google* + +[source, properties] +---- +quarkus.oidc.provider=google +quarkus.oidc.client-id={GOOGLE_CLIENT_ID} +quarkus.oidc.credentials.secret={GOOGLE_CLIENT_SECRET} +quarkus.oidc.token.issuer=https://accounts.google.com +---- + // tag::update_14_39[] Configuration options with `quarkus.oidc` prefix: @@ -387,6 +469,9 @@ Relative path for calculating a `redirect_uri` query parameter. `authentication.restore-path-after-redirect`:: The original request URI used before the authentication will be restored after the user has been redirected back to the application. (default: `true`) +`authentication.force-redirect-https-scheme`:: +Force 'https' as the 'redirect_uri' parameter scheme when running behind an SSL terminating reverse proxy. + `authentication.scopes`:: List of scopes. @@ -430,6 +515,75 @@ NOTE: With Keycloak OIDC server `https://host:port/auth/realms/{realm}` where ` TIP: You can use `quarkus.http.cors` property to enable consuming form different domain. // end::update_1_9[] +*Testing* + +You can use `@TestSecurity` annotation tooin OIDC by registering the following dependency: + +[source, xml] +---- + + io.quarkus + quarkus-test-security-oidc + test + +---- + +[source, java] +---- +@Test +@TestSecurity(user = "userOidc", roles = "viewer") +@OidcSecurity(claims = { + @Claim(key = "email", value = "user@gmail.com") +}, userinfo = { + @UserInfo(key = "sub", value = "subject") +}, config = { + @ConfigMetadata(key = "issuer", value = "issuer") +}) +public void testOidcWithClaimsUserInfoAndMetadata() {} +---- + +*DevServices* + +When testing or running in dev mode Quarkus can even provide you with a zero config Keycloak out of the box. + +Possible configuration values prefixed with `quarkus.keycloak`: + +`devservices.enabled`:: +If devservices is enabled or not. (default: `true`) + +`devservices.image-name`:: +The container image name to use instead of the default one. Keycloak-X can be used (`quay.io/keycloak/keycloak-x:15.0.2`) (default: `quay.io/keycloak/keycloak:15.0.2`) + +`devservices.keycloak-x-image`:: +Set `quarkus.devservices.keycloak.keycloak-x-image` to override this check which may be necessary if you build custom Keycloak-X or Keycloak images. You do not need to set this property if the default check works. + +`devservices.port`:: +Optional fixed port the dev service will listen to. If not defined, the port will be chosen randomly. + +`devservices.shared`:: +Indicates if the Keycloak broker managed by Quarkus Dev Services is shared. When shared, Quarkus looks for running containers using label-based service discovery. (default: `true`) + +`devservices.service-name`:: +The value of the `quarkus-dev-service-keycloak` label attached to the started container. (default: `kafka`) + +`devservices.realm-path`:: +The class or file system path to a Keycloak realm file which will be used to initialize Keycloak + +`devservices.java-opts`:: +The JAVA_OPTS passed to the keycloak JVM + +`devservices.realm-name`:: +The Keycloak realm name + +`devservices.create-realm`:: +Indicates if the Keycloak realm has to be created when the realm file pointed to by the 'realm-path' property does not exist + +`devservices.users`:: +The Keycloak users map containing the user name and password pairs + +`devservices.roles`:: +The Keycloak user roles + *Multi-tenancy* // tag::update_14_34[] @@ -450,6 +604,22 @@ quarkus.oidc.tenant-b.authentication.scopes=email,profile,openid ---- // end::update_14_34[] +You can inject `io.quarkus.oidc.client.Tokens`, `io.quarkus.oidc.OidcSession`, and `io.quarkus.oidc.client.OidcClient` to interact with OIDC. + +[source, java] +---- +@Inject +@io.quarkus.oidc.client.NamedOidcClient("client2") +OidcClient client; + +@Inject +@io.quarkus.oidc.client.NamedOidcClient("client1") +Tokens tokens1; + +@Inject +OidcSession oidcSession; +---- + == OAuth2 // tag::update_6_8[] Quarkus integrates with OAuth2 to be used in case of opaque tokens (none JWT) and its validation against an introspection endpoint. @@ -679,8 +849,6 @@ The index of column containing password hash. (default: `0`) `principal-query.bcrypt-password-mapper.hash-encoding`:: A string referencing the password hash encoding (`BASE64` or `HEX`). (default: `BASE64`) -<<< - `principal-query.bcrypt-password-mapper.salt-index`:: The index column containing the Bcrypt salt. (default: `0`) @@ -1031,6 +1199,19 @@ vaultKubernetesAuthService ---- // end::update_18_7[] +*PKI* + +[source, java] +---- +@Inject +public VaultPKISecretEngine pkiSecretEngine; + +GenerateCertificateOptions options = new GenerateCertificateOptions(); + SignedCertificate signed = pkiSecretEngine.signRequest("example-dot-com", csr, options); +return signed.certificate.getData(); +---- + + Vault configuration properties. Prefix `quarkus.vault` is skipped. @@ -1111,6 +1292,12 @@ A path in vault kv store, where we will find the kv-key Key name to search in vault path kv-path (default: `password`) // end::update_10_5[] +*DevServices* + +When testing or running in dev mode Quarkus can even provide you with a zero config Vault out of the box. + +Possible configuration values are shown at https://quarkiverse.github.io/quarkiverse-docs/quarkus-vault/dev/index.html#dev-services[Vault, window="_blank"] + == Amazon KMS // tag::update_16_23[] diff --git a/examples/quarkus-cheat-sheet/site.adoc b/examples/quarkus-cheat-sheet/site.adoc index 52443485..8b5f5047 100644 --- a/examples/quarkus-cheat-sheet/site.adoc +++ b/examples/quarkus-cheat-sheet/site.adoc @@ -12,291 +12,6 @@ Also focused on developer experience, making things just work with little to no In this page you can either read what has been added in each version of the cheat-sheet individually in <> section, see the full cheat-sheet as HTML icon:html5[] <> format or icon:file-pdf-o[] {pdf-download}[download the full cheat-sheet as PDF]. -[[whatsnew]] -== What's New in Cheat-Sheet - -=== Version 1.13.0.Final - -.DevServices -[%collapsible] -==== -include::persistence.adoc[tag=update_24_1] -==== - -.Quarkus Integration Tests -[%collapsible] -==== -include::core.adoc[tag=update_24_2] -==== - -.Native configuration properties -[%collapsible] -==== -include::cloud.adoc[tag=update_24_3] -==== - -.OpenId properties -[%collapsible] -==== -include::misc.adoc[tag=update_24_4] -==== - -.JsonbConfig -[%collapsible] -==== -include::core.adoc[tag=update_24_5] -==== - -.OpenTelemetry -[%collapsible] -==== -include::network.adoc[tag=update_24_6] -==== - -.Kubernetes Service Binding -[%collapsible] -==== -include::cloud.adoc[tag=update_24_7] -==== - -.RESTEasy Reactive-based REST Client -[%collapsible] -==== -include::core.adoc[tag=update_24_8] -==== - -=== Version 1.12.0.Final - -.Qute Value Resolvers -[%collapsible] -==== -include::misc.adoc[tag=update_23_1] -==== - -.Qute Content Filter -[%collapsible] -==== -include::misc.adoc[tag=update_23_2] -==== - -.Start multiple test resources concurrently -[%collapsible] -==== -include::core.adoc[tag=update_23_3] -==== - -.Running specific tests -[%collapsible] -==== -include::core.adoc[tag=update_23_4] -==== - -=== Version 1.11.0.Final - -.Trust All -[%collapsible] -==== -include::security.adoc[tag=update_22_1] -==== - -.Vault Transit Key -[%collapsible] -==== -include::security.adoc[tag=update_22_2] -==== - -.Switch/When Qute -[%collapsible] -==== -include::misc.adoc[tag=update_22_3] -==== - -.Injectable Logger -[%collapsible] -==== -include::core.adoc[tag=update_22_4] -==== - -.Additional Configuration Locations -[%collapsible] -==== -include::core.adoc[tag=update_22_5] -==== - -.JBang Maven creator -[%collapsible] -==== -include::misc.adoc[tag=update_22_6] -==== - -.RESTEasy Reactive -[%collapsible] -==== -include::reactive.adoc[tag=update_22_7] -==== - -.Exclusions in Native compilation -[%collapsible] -==== -include::cloud.adoc[tag=update_22_8] -==== - -.Flyway Callbacks support -[%collapsible] -==== -include::persistence.adoc[tag=update_22_9] -==== - -.Spring Data Rest -[%collapsible] -==== -include::spring.adoc[tag=update_22_10] -==== - -.Dev UI -[%collapsible] -==== -include::core.adoc[tag=update_22_11] -==== - -=== Version 1.10.0.Final - -.Add algorithms to hash passwords in embeded mode -[%collapsible] -==== -include::security.adoc[tag=update_21_1] -==== - -.Panache MongoDB Rest Data -[%collapsible] -==== -include::persistence.adoc[tag=update_21_2] -==== - -.Enabling permissions -[%collapsible] -==== -include::security.adoc[tag=update_21_3] -==== - -.OpenTracing Kafka Integration -[%collapsible] -==== -include::network.adoc[tag=update_21_4] -==== - -.BouncyCastle -[%collapsible] -==== -include::security.adoc[tag=update_21_5] -==== - -.Knative Properties -[%collapsible] -==== -include::cloud.adoc[tag=update_21_6] -==== - -.Swagger UI Properties -[%collapsible] -==== -include::misc.adoc[tag=update_21_7] -==== - -.Default to JSON -[%collapsible] -==== -include::core.adoc[tag=update_21_8] -==== - -.Amazon IAM -[%collapsible] -==== -include::security.adoc[tag=update_21_9] -==== - -=== Version 1.9.0.Final - -.JAXP -[%collapsible] -==== -include::core.adoc[tag=update_20_1] -==== - -.Multiple Redis Clients -[%collapsible] -==== -include::persistence.adoc[tag=update_20_2] -==== - -.TestTransaction -[%collapsible] -==== -include::core.adoc[tag=update_20_3] -==== - -.Instantiate client programmatically -[%collapsible] -==== -include::core.adoc[tag=update_20_4] -==== - -.Message Bundling and Localization -[%collapsible] -==== -include::misc.adoc[tag=update_20_5] -==== - -.Testing Callback -[%collapsible] -==== -include::core.adoc[tag=update_20_6] -==== - -=== Version 1.8.0.Final - -.Disable cache extension -[%collapsible] -==== -include::misc.adoc[tag=update_19_1] -==== - -.Include Qute templates -[%collapsible] -==== -include::misc.adoc[tag=update_19_2] -==== - -.Common Reactive DataSource Configuration -[%collapsible] -==== -include::reactive.adoc[tag=update_19_3] -==== - -.Export OpenAPI schema -[%collapsible] -==== -include::misc.adoc[tag=update_19_4] -==== - -.Quartz Configuration values -[%collapsible] -==== -include::misc.adoc[tag=update_19_5] -==== - -.JBang -[%collapsible] -==== -include::misc.adoc[tag=update_19_6] -==== - -.Micrometer extension -[%collapsible] -==== -include::network.adoc[tag=update_19_7] -==== - :leveloffset: +1 [[quarkuscheatsheet]] include::quarkus-cheat-sheet.adoc[] \ No newline at end of file