+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:
@@ -5638,6 +5934,90 @@
<
}
+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
-
+
+
reactive.trust-certificate-pfx
-
Trust configuration in the PFX format.
@@ -6437,6 +6949,27 @@
+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();
+}
+
+
+
+
+
+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: