Skip to content

Commit ddfa586

Browse files
committed
Sync web site with Quarkus documentation
1 parent 2bbb1b4 commit ddfa586

File tree

9 files changed

+207
-102
lines changed

9 files changed

+207
-102
lines changed

_guides/_attributes.adoc

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
// Common attributes.
22
// --> No blank lines (it ends the document header)
33
:project-name: Quarkus
4-
:quarkus-version: 3.26.1
4+
:quarkus-version: 3.26.2
55
:quarkus-platform-groupid: io.quarkus.platform
66
// .
77
:maven-version: 3.9.9
@@ -11,13 +11,13 @@
1111
:mandrel-flavor: jdk-21
1212
:surefire-version: 3.5.3
1313
:gradle-version: 9.0.0
14-
:elasticsearch-version: 9.1.2
15-
:elasticsearch-image: docker.io/elastic/elasticsearch:9.1.2
14+
:elasticsearch-version: 9.1.3
15+
:elasticsearch-image: docker.io/elastic/elasticsearch:9.1.3
1616
:opensearch-image: docker.io/opensearchproject/opensearch:3.1.0
1717
:infinispan-version: ${infinispan.version}
1818
:infinispan-protostream-version: ${infinispan.protostream.version}
19-
:logstash-image: docker.io/elastic/logstash:9.1.2
20-
:kibana-image: docker.io/elastic/kibana:9.1.2
19+
:logstash-image: docker.io/elastic/logstash:9.1.3
20+
:kibana-image: docker.io/elastic/kibana:9.1.3
2121
:keycloak-docker-image: quay.io/keycloak/keycloak:26.3.0
2222
:jandex-version: 3.4.0
2323
:jandex-gradle-plugin-version: 1.0.0

_guides/assistant.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,7 +257,7 @@ To use this state in your page:
257257
import { observeState } from 'lit-element-state'; // <1>
258258
import { assistantState } from 'assistant-state'; // <2>
259259
260-
export class QwcExtentionPage extends observeState(LitElement) { // <3>
260+
export class QwcExtensionPage extends observeState(LitElement) { // <3>
261261
----
262262
<1> import observeState from the LitState library.
263263
<2> import the state you are interested in, in this case assistant state.

_guides/command-mode-reference.adoc

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -248,7 +248,17 @@ public class HelloIT extends HelloTest {
248248
}
249249
----
250250

251-
=== Mocking
251+
=== Limitations
252+
253+
`@QuarkusMainTest` does **not** support the following features:
254+
255+
- Injection of CDI beans
256+
- Using Panache entities
257+
- Using mocks with `@InjectMock`
258+
259+
Usually, it's best to use a combination of `@QuarkusMainTest` tests for testing application externals, and `@QuarkusTest` tests for fine-grained testing which requires access to application internals.
260+
261+
==== Mocking
252262

253263
CDI injection is not supported in the `@QuarkusMainTest` tests.
254264
Consequently, mocking CDI beans with `QuarkusMock` or `@InjectMock` is not supported either.

_guides/config-reference.adoc

Lines changed: 126 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ include::_attributes.adoc[]
1212
:sectnumlevels: 4
1313
:topics: configuration
1414

15-
IMPORTANT: The content of this guide has been revised and split into additional topics. Please check the <<additional-information,Additional Information>> section.
16-
1715
In this reference guide we're going to describe various aspects of Quarkus configuration. A Quarkus application and
1816
Quarkus itself (core and extensions) are both configured via the same mechanism that leverages
1917
the https://github.com/smallrye/smallrye-config[SmallRye Config] API an implementation of the
@@ -195,9 +193,80 @@ Quarkus provides additional extensions which cover other configuration formats a
195193

196194
TIP: It is also possible to create a xref:config-extending-support.adoc#custom-config-source[Custom Config Source].
197195

198-
== Inject
196+
== ConfigMapping
197+
198+
The recommended way to expose configuration to a Quarkus application is by mapping it with an interface. With
199+
https://smallrye.io/smallrye-config/Main/config/mappings/[SmallRye Config Mappings], it is possible to
200+
group multiple configuration properties in a single interface that share the same prefix (or namespace). It supports
201+
the following set of features:
202+
203+
* Automatic conversion of the configuration type, including List, Set, Map, Optional, and primitive types.
204+
* Nested Config Mapping groups.
205+
* Configuration Properties Naming Strategies
206+
* Integration with Bean Validation
199207

200-
Quarkus uses https://microprofile.io/project/eclipse/microprofile-config[MicroProfile Config] annotations to inject the
208+
A Config Mapping requires an interface with minimal metadata configuration annotated with
209+
`@io.smallrye.config.ConfigMapping`:
210+
211+
[source,java]
212+
----
213+
@ConfigMapping(prefix = "server")
214+
public interface Server {
215+
String host();
216+
217+
int port();
218+
219+
int sslPort();
220+
}
221+
----
222+
223+
A complex object type uses the following rules to map configuration values to their member values:
224+
225+
* A configuration path is built by taking the object type prefix (or namespace) and the mapping member name
226+
* The member name is converted to its kebab-case format
227+
* If the member name is represented as a getter, the member name is taken from its property name equivalent, and then
228+
converted to its kebab-case format.
229+
* The configuration value is automatically converted to the member type
230+
* The configuration path is required to exist with a valid configuration value or the mapping will fail.
231+
232+
NOTE: Kebab-case - the method name is derived by replacing case changes with a dash to map the configuration property.
233+
234+
The `Server` interface can map configuration properties with the name `server.host` into the `Server.host()`
235+
method, `server.port` into `Server.port()` method, and `server.ssl-port` into `Server.sslPort()` method. The
236+
configuration property name to look up is constructed from the prefix and the method name (in kebab-case), separated
237+
by adot (`.`) character.
238+
239+
A `@ConfigMapping` can be injected into any CDI aware bean:
240+
241+
[source,java]
242+
----
243+
@ApplicationScoped
244+
class BusinessBean {
245+
@Inject
246+
Server server;
247+
248+
void businessMethod() {
249+
String host = server.host();
250+
}
251+
}
252+
----
253+
254+
For non-CDI components, use the `io.smallrye.config.SmallRyeConfig#getConfigMapping` API to retrieve the config mapping
255+
instance:
256+
257+
[source,java]
258+
----
259+
SmallRyeConfig config = ConfigProvider.getConfig().unwrap(SmallRyeConfig.class);
260+
Server server = config.getConfigMapping(Server.class);
261+
----
262+
263+
TIP: Check the xref:config-mappings.adoc[Mapping configuration to objects] guide for advanced usages with
264+
`@ConfigMapping`.
265+
266+
== ConfigProperty
267+
268+
While `@ConfigMapping` is the recommended approach, Quarkus also supports
269+
https://microprofile.io/project/eclipse/microprofile-config[MicroProfile Config] annotations to inject the
201270
configuration properties in the application.
202271

203272
[source,java]
@@ -221,19 +290,20 @@ String suffix;
221290
@ConfigProperty(name = "greeting.name")
222291
Optional<String> name; <3>
223292
----
224-
<1> If you do not provide a value for this property, the application startup fails with `jakarta.enterprise.inject.spi.DeploymentException: No config value of type [class java.lang.String] exists for: greeting.message`.
293+
<1> If you do not provide a value for this property, the application startup fails with
294+
`io.quarkus.runtime.configuration.ConfigurationException: Failed to load config value of type class java.lang.String for: greeting.messagee`.
225295
<2> The default value is injected if the configuration does not provide a value for `greeting.suffix`.
226296
<3> This property is optional - an empty `Optional` is injected if the configuration does not provide a value for `greeting.name`.
227297

228298
TIP: Use xref:config-mappings.adoc#config-mappings[Config Mappings] to group similar configuration properties.
229299

230-
=== Default Values
300+
== Default Values
231301

232-
If a property is associated with a default value (by way of the `defaultValue` attribute), and no configuration value
233-
is supplied for the property, then rather than throwing a `jakarta.enterprise.inject.spi.DeploymentException`, the
234-
default value will be used. The `defaultValue` value is expressed as a `String`, and uses the same conversion mechanism
235-
used to process configuration values. Several Built-in Converters already exist for primitives, boxed primitives, and
236-
other classes; for example:
302+
If a configuration is associated with a default value (by way of the `io.smallrye.config.WithDefault` or
303+
`org.eclipse.microprofile.config.inject.ConfigProperty.defaultValue`), and no configuration value is supplied for the
304+
property, then rather than throwing an exception, the default value will be used. A default value is expressed as a
305+
`String`, and uses the same conversion mechanism used to process configuration values. Several Built-in Converters
306+
already exist for primitives, boxed primitives, and other classes; for example:
237307

238308
* Primitives: `boolean`, `byte`, `short`, etc.
239309
* Boxed primitives: `java.lang.Boolean`, `java.lang.Byte`, `java.lang.Short`, etc.
@@ -248,10 +318,10 @@ these converters comply with the Microprofile or custom implementation providers
248318
* Boolean values will be `true` in cases "true", "1", "YES", "Y" "ON". Otherwise, value will be interpreted as false
249319
* For float and double values the fractional digits must be separated by a dot `.`
250320

251-
Note that when a combination of `Optional*` types and the `defaultValue` attribute are used, the defined `defaultValue`
252-
will still be used and if no value is given for the property, the `Optional*` will be present and populated with the
253-
converted default value. However, when the property is explicitly empty, the default value is not used and the
254-
`Optional` will be empty. Consider this example:
321+
Note that when a combination of `Optional*` types and defaults are used, the defined default value will still be used
322+
and if no value is given for the property, the `Optional*` will be present and populated with the converted default
323+
value. However, when the property is explicitly empty, the default value is not used and the `Optional` will be empty.
324+
Consider this example:
255325

256326
[source,properties]
257327
----
@@ -274,23 +344,16 @@ greeting.suffix=
274344
will result in a `java.util.NoSuchElementException: SRCFG02004: Required property greeting.message not found` on
275345
startup and the default value will not be assigned.
276346

277-
Below is an example of a Quarkus-supplied converter:
278-
279-
[source,java]
280-
----
281-
@ConfigProperty(name = "server.address", defaultValue = "192.168.1.1")
282-
InetAddress serverAddress;
283-
----
284-
285347
== Programmatically access
286348

287-
The `org.eclipse.microprofile.config.ConfigProvider.getConfig()` API allows to access the Config API programmatically.
349+
The `io.smallrye.config.SmallRyeConfig` API allows to access the Config API programmatically.
288350
This API is mostly useful in situations where CDI injection is not available.
289351

290352
[source,java]
291353
----
292-
String databaseName = ConfigProvider.getConfig().getValue("database.name", String.class);
293-
Optional<String> maybeDatabaseName = ConfigProvider.getConfig().getOptionalValue("database.name", String.class);
354+
SmallRyeConfig config = org.eclipse.microprofile.config.ConfigProvider.getConfig().unwrap(SmallRyeConfig.class);
355+
String databaseName = config.getValue("database.name", String.class);
356+
Optional<String> maybeDatabaseName = config.getOptionalValue("database.name", String.class);
294357
----
295358

296359
IMPORTANT: Do not use `System.getProperty(String)` or `System.getEnv(String)` to retrieve configuration values. These
@@ -496,17 +559,6 @@ Multiple profiles priority work in reverse order. With `quarkus.profile=common,d
496559
profile and then the `common` profile.
497560
====
498561

499-
=== Default Runtime Profile
500-
501-
The default Quarkus runtime profile is set to the profile used to build the application:
502-
503-
[source,bash]
504-
----
505-
./mvnw package -Dnative -Dquarkus.profile=prod-aws
506-
./target/my-app-1.0-runner // <1>
507-
----
508-
<1> The command will run with the `prod-aws` profile. This can be overridden using the `quarkus.profile` configuration.
509-
510562
[[property-expressions]]
511563
== Property Expressions
512564

@@ -674,19 +726,51 @@ extensions. Therefore, the `quarkus.` prefix should **never** be used for applic
674726

675727
=== Build Time configuration
676728

677-
Some Quarkus configurations only take effect during build time, meaning it is not possible to change them at runtime. These
678-
configurations are still available at runtime but as read-only and have no effect in Quarkus behaviour. A change to any
679-
of these configurations requires a rebuild of the application itself to reflect changes of such properties.
729+
Some Quarkus configurations only take effect during build time (compile), meaning it is not possible to change it at
730+
runtime. These configurations are still available at runtime but as read-only and have no effect in Quarkus
731+
behaviour. A change to any of these configurations requires a rebuild of the application itself to reflect changes of
732+
such properties. This allows Quarkus to provide optimizations and reduce complexity based on the current build
733+
configuration. By default, Quarkus uses the `prod` configuration profile to build the application.
680734

681735
TIP: The properties fixed at build time are marked with a lock icon (icon:lock[]) in the xref:all-config.adoc[list of all configuration options].
682736

683737
However, some extensions do define properties _overridable at runtime_. A simple example is the database URL, username
684738
and password which is only known specifically in your target environment, so they can be set and influence the
685739
application behaviour at runtime.
686740

687-
== Change build time properties after your application has been published
741+
=== Config Recording
742+
743+
During the build process, Quarkus proceeds to record the available configuration in the final binary, to ensure it can
744+
start successfully in runtime, without missing required configuration. The following sources are excluded from
745+
recording:
746+
747+
* System Properties
748+
* Environment Variables
749+
* `.env`
750+
* Build System Sources (provided by Maven or Gradle)
751+
752+
=== Default Runtime Profile
753+
754+
The default Quarkus runtime profile is set to the profile used to build the application:
755+
756+
[source,bash]
757+
----
758+
./mvnw package -Dnative -Dquarkus.profile=prod-aws
759+
./target/my-app-1.0-runner // <1>
760+
----
761+
<1> The command will run with the `prod-aws` profile. This can be overridden using the `quarkus.profile` configuration.
762+
763+
[IMPORTANT]
764+
====
765+
Using a different configuration profile at runtime from the one used to build the application can lead to unexpected
766+
results.
767+
====
768+
769+
== Change configuration after build (Reaugmentation)
688770

689-
If you are in the rare situation that you need to change the build time configuration after your application is built, then check out how xref:reaugmentation.adoc[re-augmentation] can be used to rebuild the augmentation output for a different build time configuration.
771+
If you are in the rare situation that you need to change the build time configuration after your application is built,
772+
then check out how xref:reaugmentation.adoc[re-augmentation] can be used to rebuild the augmentation output for a
773+
different build time configuration.
690774

691775
== Tracking effective build time configuration used at build time
692776

_guides/dev-ui.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -872,7 +872,7 @@ To use this state in your page:
872872
import { observeState } from 'lit-element-state'; // <1>
873873
import { connectionState } from 'connection-state'; // <2>
874874
875-
export class QwcExtentionPage extends observeState(LitElement) { // <3>
875+
export class QwcExtensionPage extends observeState(LitElement) { // <3>
876876
----
877877
<1> import observeState from the LitState library.
878878
<2> import the state you are interested in, in this case connection state.
@@ -900,7 +900,7 @@ To use this state in your page:
900900
import { observeState } from 'lit-element-state'; // <1>
901901
import { themeState } from 'theme-state'; // <2>
902902
903-
export class QwcExtentionPage extends observeState(LitElement) { // <3>
903+
export class QwcExtensionPage extends observeState(LitElement) { // <3>
904904
----
905905
<1> import observeState from the LitState library.
906906
<2> import the state you are interested in, in this case theme state.
@@ -934,7 +934,7 @@ To use this state in your page:
934934
import { observeState } from 'lit-element-state'; // <1>
935935
import { assistantState } from 'assistant-state'; // <2>
936936
937-
export class QwcExtentionPage extends observeState(LitElement) { // <3>
937+
export class QwcExtensionPage extends observeState(LitElement) { // <3>
938938
----
939939
<1> import observeState from the LitState library.
940940
<2> import the state you are interested in, in this case assistant state.

_guides/opentelemetry-metrics.adoc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -362,9 +362,9 @@ IMPORTANT: Each unique combination of metric name and dimension produces a uniqu
362362
Using an unbounded set of dimensional data (many different values like a userId) can lead to a "cardinality explosion", an exponential increase in the creation of new time series.
363363
Avoid!
364364

365-
OpenTelemetry provides many other types of Counters: `LongUpDownCounter`, `DoubleCounter`, `DoubleUpDownCounter` and also Observable, async counters like `ObservableLongCounter`, `ObservableDoubleCounter`, `ObservableLongUpDownCounter` and `ObservableDoubleUpDownCounter`.
365+
OpenTelemetry provides many other types of Counters: `LongUpDownCounter`, `DoubleCounter`, `UpDownCounter`, `DoubleUpDownCounter` and also Observable, async counters like `ObservableLongCounter`, `ObservableDoubleCounter`, `ObservableLongUpDownCounter` and `ObservableDoubleUpDownCounter`.
366366

367-
For more details please refer to the https://opentelemetry.io/docs/languages/java/instrumentation/#using-counters[OpenTelemetry Java documentation about Counters].
367+
For more details please refer to the https://opentelemetry.io/docs/languages/java/api/#counter[OpenTelemetry Java documentation about Counters].
368368

369369
=== Gauges
370370
Observable Gauges should be used to measure non-additive values.

_guides/opentelemetry.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ You can also use the xref:logging-exporter-for-debugging[logging exporter] to ou
398398

399399
Quarkus supports the OpenTelemetry Autoconfiguration for Traces.
400400
The configurations match what you can see at
401-
https://github.com/open-telemetry/opentelemetry-java/blob/main/sdk-extensions/autoconfigure/README.md[OpenTelemetry SDK Autoconfigure]
401+
https://opentelemetry.io/docs/languages/java/configuration/[OpenTelemetry SDK Autoconfigure]
402402
adding the usual `quarkus.*` prefix.
403403

404404
Quarkus OpenTelemetry configuration properties now have the `quarkus.otel.*` prefix.

_guides/rest.adoc

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -917,6 +917,15 @@ See <<execution-model,Execution Model documentation>> for more information.
917917
The link:{jdkapi}/java/util/concurrent/CompletionStage.html[`CompletionStage`] return
918918
type is also supported.
919919

920+
==== Request cancellation
921+
922+
Async endpoints that return `Uni` support request cancellation, which means that if the underlying HTTP connection is closed for whatever reason,
923+
the request pipeline defined by the returned `Uni` is also cancelled. This can be very useful in avoiding unnecessary work on the server
924+
when the client isn't going to use the response anyway.
925+
926+
If instead of cancelling the pipeline, it should be completed regardless of the state of the HTTP connection, Quarkus REST provides the `org.jboss.resteasy.reactive.server.Cancellable` annotation
927+
which can be applied to REST classes or methods to control the cancellation behavior.
928+
920929
=== Streaming support
921930

922931
If you want to stream your response element by element, you can make your endpoint method return a

0 commit comments

Comments
 (0)