You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ja...@apache.org on 2020/09/22 10:48:46 UTC

[camel-quarkus] 02/03: doc(mongodb): adding named connection

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

jamesnetherton pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/camel-quarkus.git

commit d64ec112594a079ca281e7c438cb692c7acd3231
Author: Pasquale Congiusti <pa...@gmail.com>
AuthorDate: Fri Sep 4 11:21:31 2020 +0200

    doc(mongodb): adding named connection
    
    Adding documentation to explain how to configure a named MongoDB client connection
    
    Ref #1608
---
 .../ROOT/pages/reference/extensions/mongodb.adoc   | 23 ++++++++++++++++++++++
 .../runtime/src/main/doc/configuration.adoc        | 23 ++++++++++++++++++++++
 2 files changed, 46 insertions(+)

diff --git a/docs/modules/ROOT/pages/reference/extensions/mongodb.adoc b/docs/modules/ROOT/pages/reference/extensions/mongodb.adoc
index d73a860..bdb362d 100644
--- a/docs/modules/ROOT/pages/reference/extensions/mongodb.adoc
+++ b/docs/modules/ROOT/pages/reference/extensions/mongodb.adoc
@@ -45,3 +45,26 @@ The Camel Quarkus MongoDB extension automatically registers a MongoDB client bea
     from("direct:start")
     .to("mongodb:camelMongoClient?database=myDb&collection=myCollection&operation=findAll")
 
+You can also create a "named" client and reference in your route by injecting a client and the related configuration as explained in the https://quarkus.io/guides/mongodb#named-mongo-client-injection[Quarkus MongoDB extension client injection]. For example:
+
+....
+//application.properties
+quarkus.mongodb.mongoClient1.connection-string = mongodb://root:example@localhost:27017/
+....
+....
+//Routes.java
+
+    @ApplicationScoped
+    public class Routes extends RouteBuilder {
+        @Inject
+        @MongoClientName("mongoClient1")
+        MongoClient mongoClient1;
+
+        @Override
+        public void configure() throws Exception {
+            from("direct:start")
+                    .to("mongodb:mongoClient1?database=myDb&collection=myCollection&operation=findAll");
+        }
+    }
+....
+
diff --git a/extensions/mongodb/runtime/src/main/doc/configuration.adoc b/extensions/mongodb/runtime/src/main/doc/configuration.adoc
index 31338d1..cfc40dd 100644
--- a/extensions/mongodb/runtime/src/main/doc/configuration.adoc
+++ b/extensions/mongodb/runtime/src/main/doc/configuration.adoc
@@ -6,3 +6,26 @@ The Camel Quarkus MongoDB extension automatically registers a MongoDB client bea
 
     from("direct:start")
     .to("mongodb:camelMongoClient?database=myDb&collection=myCollection&operation=findAll")
+
+You can also create a "named" client and reference in your route by injecting a client and the related configuration as explained in the https://quarkus.io/guides/mongodb#named-mongo-client-injection[Quarkus MongoDB extension client injection]. For example:
+
+....
+//application.properties
+quarkus.mongodb.mongoClient1.connection-string = mongodb://root:example@localhost:27017/
+....
+....
+//Routes.java
+
+    @ApplicationScoped
+    public class Routes extends RouteBuilder {
+        @Inject
+        @MongoClientName("mongoClient1")
+        MongoClient mongoClient1;
+
+        @Override
+        public void configure() throws Exception {
+            from("direct:start")
+                    .to("mongodb:mongoClient1?database=myDb&collection=myCollection&operation=findAll");
+        }
+    }
+....
\ No newline at end of file