You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by jp...@apache.org on 2022/04/12 08:11:08 UTC

[camel-spring-boot] branch main updated: [CAMEL-17933] Add documentation on configuring camel starters (#510)

This is an automated email from the ASF dual-hosted git repository.

jpoth pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel-spring-boot.git


The following commit(s) were added to refs/heads/main by this push:
     new 6002c8d9188 [CAMEL-17933] Add documentation on configuring camel starters (#510)
6002c8d9188 is described below

commit 6002c8d9188319de8e2484ab4954517909626f5b
Author: John Poth <po...@gmail.com>
AuthorDate: Tue Apr 12 10:11:02 2022 +0200

    [CAMEL-17933] Add documentation on configuring camel starters (#510)
---
 .../src/main/docs/spring-boot.adoc                 |  2 +-
 .../src/main/docs/starter-configuration.adoc       | 65 ++++++++++++++++++++++
 docs/spring-boot/modules/ROOT/nav.adoc             |  1 +
 docs/spring-boot/modules/ROOT/pages/index.adoc     |  2 +-
 4 files changed, 68 insertions(+), 2 deletions(-)

diff --git a/core/camel-spring-boot/src/main/docs/spring-boot.adoc b/core/camel-spring-boot/src/main/docs/spring-boot.adoc
index dfc2d044137..cd5503bf268 100644
--- a/core/camel-spring-boot/src/main/docs/spring-boot.adoc
+++ b/core/camel-spring-boot/src/main/docs/spring-boot.adoc
@@ -248,7 +248,7 @@ following Spring properties:
 camel.springboot.consumer-template-cache-size = 100
 camel.springboot.producer-template-cache-size = 200
 ----
-
+[[typeconverter]]
 == Auto-configured TypeConverter
 
 Camel auto-configuration registers a `TypeConverter` instance named
diff --git a/core/camel-spring-boot/src/main/docs/starter-configuration.adoc b/core/camel-spring-boot/src/main/docs/starter-configuration.adoc
new file mode 100644
index 00000000000..577fe20944f
--- /dev/null
+++ b/core/camel-spring-boot/src/main/docs/starter-configuration.adoc
@@ -0,0 +1,65 @@
+[[Component-configuration]]
+= Starter Configuration
+
+Clear and accessible configuration is a crucial part of any application. Camel xref:list.adoc[starters] (Components, Data Formats, Languages) fully support Spring Boot's https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.external-config[external configuration] mechanism. We've also added the possibility to configure them through Spring https://docs.spring.io/spring-framework/docs/current/reference/html/core.html#beans-definition[Beans] for more complex  [...]
+
+== Using External Configuration
+
+Internally, every xref:list.adoc[starter] is configured through Spring Boot's https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.external-config.typesafe-configuration-properties.java-bean-binding[ConfigurationProperties]. Each configuration parameter can be set in various https://docs.spring.io/spring-boot/docs/current/reference/html/features.html#features.external-config[ways] (`application.[properties|json|yaml]` files, command line arguments, enviro [...]
+
+For example to configure the URL of the ActiveMQ broker you can set:
+
+[source]
+----
+camel.component.activemq.broker-url=tcp://localhost:61616
+----
+
+Or to configure the `delimeter` of the CSV dataformat to be a semicolon(;) you can set:
+
+[source]
+----
+camel.dataformat.csv.delimiter=;
+----
+
+Camel will use it's xref:spring-boot.adoc#typeconverter[TypeConverter] mechanism when setting properties to the desired type.
+
+You can refer to beans in the Registry using the `#bean:name`:
+
+[source]
+----
+camel.component.jms.transactionManager=#bean:myjtaTransactionManager
+----
+
+The `Bean` would be typically created in Java:
+
+[source,java]
+----
+@Bean("myjtaTransactionManager")
+public JmsTransactionManager myjtaTransactionManager(PooledConnectionFactory pool) {
+    JmsTransactionManager manager = new JmsTransactionManager(pool);
+    manager.setDefaultTimeout(45);
+    return manager;
+}
+----
+
+Beans can also be created in https://camel.apache.org/components/latest/others/main.html#_specifying_custom_beans[configuration files] but it isn't recommended for complex use cases.
+
+== Using Beans
+
+Starters can also be created and configured via Spring https://docs.spring.io/spring-framework/docs/current/reference/html/core.html#beans-definition[Beans]. Before creating a starter (Component, Dataformat, Language), Camel will first lookup it up in the Registry by it's name if it already exists. For example to configure a Kafka component:
+
+[source,java]
+----
+@Bean("kafka")
+public KafkaComponent kafka(KafkaConfiguration kafkaconfiguration){
+    return ComponentsBuilderFactory.kafka()
+                        .brokers("{{kafka.host}}:{{kafka.port}}")
+                        .build();
+}
+----
+
+The `Bean` name has to be equal to that of the Component, Dataformat or Language your are configuring. If the `Bean` name isn't specified in the annotation it will be set to the method name.
+
+Typical Camel Spring Boot projects will use a combination of external configuration and Beans to configure their application. For more complete examples on how to configure your Camel Spring Boot project, you can refer to our example https://github.com/apache/camel-spring-boot-examples[repository].
+
+All contributions are welcome!
\ No newline at end of file
diff --git a/docs/spring-boot/modules/ROOT/nav.adoc b/docs/spring-boot/modules/ROOT/nav.adoc
index 11e0ef4407e..6a0838607d3 100644
--- a/docs/spring-boot/modules/ROOT/nav.adoc
+++ b/docs/spring-boot/modules/ROOT/nav.adoc
@@ -1,5 +1,6 @@
 * xref:index.adoc[About]
 * xref:spring-boot.adoc[Camel Context starter]
 * xref:list.adoc[List of starters]
+* xref:starter-confuguration.adoc[Starter Configuration]
 //* xref:_list-old.adoc[old List of starters]
 
diff --git a/docs/spring-boot/modules/ROOT/pages/index.adoc b/docs/spring-boot/modules/ROOT/pages/index.adoc
index 052f62f2603..bae8e841118 100644
--- a/docs/spring-boot/modules/ROOT/pages/index.adoc
+++ b/docs/spring-boot/modules/ROOT/pages/index.adoc
@@ -72,7 +72,7 @@ camel.springboot.main-run-controller = true
 
 == Spring Boot configuration support
 
-Each xref:list.adoc[component starter] lists configuration parameters you can configure in the standard `application.properties` or `application.yml` files. These parameters have the form of `camel.component.[component-name].[parameter]`. For example to configure the URL of the ActiveMQ broker you can set:
+Each xref:list.adoc[starter] lists configuration parameters you can configure in the standard `application.properties` or `application.yml` files. These parameters have the form of `camel.component.[component-name].[parameter]`. For example to configure the URL of the ActiveMQ broker you can set:
 
 [source]
 ----