Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 7. Configuring Camel K integrations
This chapter explains available options for configuring Red Hat Integration - Camel K integrations using properties:
- Section 7.1, “Configuring Camel K integrations using properties”
- Section 7.2, “Configuring Camel K integrations using property files”
- Section 7.3, “Configuring Camel K properties using an OpenShift ConfigMap”
- Section 7.4, “Configuring Camel K properties using an OpenShift Secret”
- Section 7.5, “Configuring Camel integration components”
- Section 7.6, “Configuring Camel K integration dependencies”
7.1. Configuring Camel K integrations using properties Link kopierenLink in die Zwischenablage kopiert!
You can configure properties for Camel K integrations on the command line at runtime. When you define a property in an integration using a property placeholder, for example, {{my.message}}, you can specify the property value on the command line, for example --property my.message=Hello. You can specify multiple properties in a single command.
Procedure
Develop a Camel integration that uses a property. The following simple route includes a
{{my.message}}property placeholder:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Enter the
kamel runcommand using the--propertyoption to set the property value at runtime. For example:kamel run --property my.message="Hola Mundo" HelloCamelK.java --dev
$ kamel run --property my.message="Hola Mundo" HelloCamelK.java --dev ... [1] 2020-04-13 15:39:59.213 INFO [main] ApplicationRuntime - Listener org.apache.camel.k.listener.RoutesDumper@6e0dec4a executed in phase Started [1] 2020-04-13 15:40:00.237 INFO [Camel (camel-k) thread #1 - timer://java] info - Exchange[ExchangePattern: InOnly, BodyType: String, Body: Hola Mundo from java] ...Copy to Clipboard Copied! Toggle word wrap Toggle overflow
7.2. Configuring Camel K integrations using property files Link kopierenLink in die Zwischenablage kopiert!
You can configure multiple properties for Camel K integrations by specifying a property file on the command line at runtime. When you define properties in an integration using property placeholders, for example, {{my.items}}, you can specify the property values on the command line using a properties file, for example --property-file my-integration.properties.
Procedure
Define your integration properties file. The following shows a simple example from a
routing.propertiesfile:List of items for random generation Marker to identify priority items
# List of items for random generation items=*radiator *engine *door window # Marker to identify priority items priority-marker=*Copy to Clipboard Copied! Toggle word wrap Toggle overflow Develop a Camel integration that uses properties defined in the properties file. The following example from the
Routing.javaintegration uses the{{items}}and{{priority-marker}}property placeholders:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Enter the
kamel runcommand with the--property-fileoption. For example:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
7.3. Configuring Camel K properties using an OpenShift ConfigMap Link kopierenLink in die Zwischenablage kopiert!
You can configure multiple properties for Camel K integrations using an OpenShift ConfigMap. When you define properties in an integration using property placeholders, for example, {{my.message}}, you can specify the property values at runtime using a ConfigMap. You can also specify additional properties such as logging levels in the application.properties section of the ConfigMap.
Procedure
Develop a Camel integration that uses properties. The following simple route includes the
{{my.message}}property placeholder:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Define a ConfigMap that contains your configuration properties. For example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow This example sets the value of the
my.messageproperty and sets the logging level for theorg.apache.camelpackage in theapplication.properties.Create the ConfigMap in the same OpenShift namespace as your integration:
oc apply -f my-configmap.yaml
$ oc apply -f my-configmap.yaml configmap/my-configmap createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Run the integration with the
--configmapoption to specify the configuration properties in the ConfigMap:Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Additional resources
7.4. Configuring Camel K properties using an OpenShift Secret Link kopierenLink in die Zwischenablage kopiert!
You can configure multiple properties for Camel K integrations using an OpenShift Secret. When you define properties in an integration using property placeholders, for example, {{my.message}}, you can specify the property values at runtime using a Secret. You can also specify additional properties such as logging levels in the application.properties section of the Secret.
Configuring integration properties using a Secret is similar to configuring using a ConfigMap. The main difference is that you may need to base64-encode the content of the application.properties in the Secret.
Procedure
Develop a Camel integration that uses properties. The following simple route includes the
{{my.message}}property placeholder:Copy to Clipboard Copied! Toggle word wrap Toggle overflow Define a Secret that contains your configuration properties. For example:
Copy to Clipboard Copied! Toggle word wrap Toggle overflow This example sets the value of the
my.messageproperty toHello Worldand sets the logging level for theorg.apache.camelpackage toDEBUG. These settings are specified in base64-encoded format in theapplication.properties.Create the Secret in the same OpenShift namespace as your integration:
oc apply -f my-secret.yaml
$ oc apply -f my-secret.yaml secret/my-secret createdCopy to Clipboard Copied! Toggle word wrap Toggle overflow Run the integration with the
--secretoption to specify the configuration properties in the Secret:kamel run --secret=my-secret HelloCamelK.java --dev
$ kamel run --secret=my-secret HelloCamelK.java --dev [1] 2020-04-14 14:30:29.788 DEBUG [Camel (camel-k) thread #1 - timer://java] DefaultReactiveExecutor - Queuing reactive work: CamelInternalProcessor - UnitOfWork - afterProcess - DefaultErrorHandler[sendTo(log://info)] - ID-hello-camel-k-68f85d99b9-srd92-1586874486770-0-144 [1] 2020-04-14 14:30:29.789 DEBUG [Camel (camel-k) thread #1 - timer://java] SendProcessor - >>>> log://info Exchange[ID-hello-camel-k-68f85d99b9-srd92-1586874486770-0-144] [1] 2020-04-14 14:30:29.789 INFO [Camel (camel-k) thread #1 - timer://java] info - Exchange[ExchangePattern: InOnly, BodyType: String, Body: Hello World from java]Copy to Clipboard Copied! Toggle word wrap Toggle overflow
Additional resources
7.5. Configuring Camel integration components Link kopierenLink in die Zwischenablage kopiert!
You can configure Camel components programmatically in your integration code or by using configuration properties on the command line at runtime. You can configure Camel components using the following syntax:
camel.component.${scheme}.${property}=${value}
camel.component.${scheme}.${property}=${value}
For example, to change the queue size of the Camel seda component for staged event-driven architecture, you can configure the following property on the command line:
camel.component.seda.queueSize=10
camel.component.seda.queueSize=10
Procedure
Enter the
kamel runcommand and specify the Camel component configuration using the--propertyoption. For example:kamel run --property camel.component.seda.queueSize=10 examples/Integration.java
$ kamel run --property camel.component.seda.queueSize=10 examples/Integration.javaCopy to Clipboard Copied! Toggle word wrap Toggle overflow
7.6. Configuring Camel K integration dependencies Link kopierenLink in die Zwischenablage kopiert!
Camel K automatically resolves a wide range of dependencies that are required to run your integration code. However, you can explicitly add dependencies on the command line at runtime using the kamel run --dependency option.
The following example integration uses Camel K automatic dependency resolution:
...
from("imap://admin@myserver.com")
.to("seda:output")
...
...
from("imap://admin@myserver.com")
.to("seda:output")
...
Because this integration has an endpoint starting with the imap: prefix, Camel K can automatically add the camel-mail component to the list of required dependencies. The seda: endpoint belongs to camel-core, which is automatically added to all integrations, so Camel K does not add additional dependencies for this component.
Camel K automatic dependency resolution is transparent to the user at runtime. This is very useful in development mode because you can quickly add all the components that you need without exiting the development loop.
You can explicitly add a dependency using the kamel run --dependency or -d option. You might need to use this to specify dependencies that are not included in the Camel catalog. You can specify multiple dependencies on the command line.
Procedure
Enter the
kamel runcommand and specify dependencies using the-doption. For example:kamel run -d mvn:com.google.guava:guava:26.0-jre -d camel-mina2 Integration.java
$ kamel run -d mvn:com.google.guava:guava:26.0-jre -d camel-mina2 Integration.javaCopy to Clipboard Copied! Toggle word wrap Toggle overflow
You can disable automatic dependency resolution by disabling the dependencies trait: -trait dependencies.enabled=false. However, this is not recommended in most cases.