此内容没有您所选择的语言版本。
Chapter 4. Configuration
Camel Quarkus automatically configures and deploys a Camel Context bean which by default is started/stopped according to the Quarkus Application lifecycle. The configuration step happens at build time during Quarkus' augmentation phase and it is driven by the Camel Quarkus extensions which can be tuned using Camel Quarkus specific quarkus.camel.* properties.
quarkus.camel.* configuration properties are documented on the individual extension pages - for example see Camel Quarkus Core.
After the configuration is done, a minimal Camel Runtime is assembled and started in the RUNTIME_INIT phase.
4.1. Configuring Camel components 复制链接链接已复制到粘贴板!
4.1.1. application.properties 复制链接链接已复制到粘贴板!
To configure components and other aspects of Apache Camel through properties, make sure that your application depends on camel-quarkus-core directly or transitively. Because most Camel Quarkus extensions depend on camel-quarkus-core, you typically do not need to add it explicitly.
camel-quarkus-core brings functionalities from Camel Main to Camel Quarkus.
In the example below, you set a specific ExchangeFormatter configuration on the LogComponent via application.properties:
camel.component.log.exchange-formatter = #class:org.apache.camel.support.processor.DefaultExchangeFormatter camel.component.log.exchange-formatter.show-exchange-pattern = false camel.component.log.exchange-formatter.show-body-type = false
camel.component.log.exchange-formatter = #class:org.apache.camel.support.processor.DefaultExchangeFormatter
camel.component.log.exchange-formatter.show-exchange-pattern = false
camel.component.log.exchange-formatter.show-body-type = false
4.1.2. CDI 复制链接链接已复制到粘贴板!
You can also configure a component programmatically using CDI.
The recommended method is to observe the ComponentAddEvent and configure the component before the routes and the CamelContext are started:
4.1.2.1. Producing a @Named component instance 复制链接链接已复制到粘贴板!
Alternatively, you can create and configure the component yourself in a @Named producer method. This works as Camel uses the component URI scheme to look-up components from its registry. For example, in the case of a LogComponent Camel looks for a log named bean.
Please note that while producing a @Named component bean will usually work, it may cause subtle issues with some components.
Camel Quarkus extensions may do one or more of the following:
- Pass custom subtype of the default Camel component type. See the Vert.x WebSocket extension example.
- Perform some Quarkus specific customization of the component. See the JPA extension example.
These actions are not performed when you produce your own component instance, therefore, configuring components in an observer method is the recommended method.
- 1
- The
"log"argument of the@Namedannotation can be omitted if the name of the method is the same.
4.2. Configuration by convention 复制链接链接已复制到粘贴板!
In addition to support configuring Camel through properties, camel-quarkus-core allows you to use conventions to configure the Camel behavior. For example, if there is a single ExchangeFormatter instance in the CDI container, then it will automatically wire that bean to the LogComponent.
4.3. Metering labels 复制链接链接已复制到粘贴板!
You can apply labels to pods using the Metering Operator on OpenShift Container Platform version 4.8 and earlier. From version 4.9 onward, the Metering Operator is no longer available without a direct replacement.
Do not add metering labels to any pods that an operator or a template deploys and manages.
Camel Quarkus can use the following metering labels:
-
com.company: Red_Hat -
rht.prod_name: Red_Hat_Integration -
rht.prod_ver: 2021.Q4 -
rht.comp: "Camel-Quarkus" -
rht.comp_ver: 2.2.0 -
rht.subcomp: {sub-component-name} -
rht.subcomp_t: application