Dieser Inhalt ist in der von Ihnen ausgewählten Sprache nicht verfügbar.
Chapter 56. MongoDB
Perform operations on MongoDB documents and collections.
56.1. What’s inside Link kopierenLink in die Zwischenablage kopiert!
-
MongoDB component, URI syntax:
mongodb:connectionBean
Please refer to the above link for usage and configuration details.
56.2. Maven coordinates Link kopierenLink in die Zwischenablage kopiert!
Create a new project with this extension on code.quarkus.redhat.com
Or add the coordinates to your existing project:
<dependency> <groupId>org.apache.camel.quarkus</groupId> <artifactId>camel-quarkus-mongodb</artifactId> </dependency>
<dependency>
<groupId>org.apache.camel.quarkus</groupId>
<artifactId>camel-quarkus-mongodb</artifactId>
</dependency>
56.3. Additional Camel Quarkus configuration Link kopierenLink in die Zwischenablage kopiert!
The extension leverages the Quarkus MongoDB Client extension. The Mongo client can be configured via the Quarkus MongoDB Client configuration options.
The Camel Quarkus MongoDB extension automatically registers a MongoDB client bean named camelMongoClient
. This can be referenced in the mongodb endpoint URI connectionBean
path parameter. For example:
from("direct:start") .to("mongodb:camelMongoClient?database=myDb&collection=myCollection&operation=findAll")
from("direct:start")
.to("mongodb:camelMongoClient?database=myDb&collection=myCollection&operation=findAll")
If your application needs to work with multiple MongoDB servers, you can create a "named" client and reference in your route by injecting a client and the related configuration as explained in the Quarkus MongoDB extension client injection. For example:
//application.properties quarkus.mongodb.mongoClient1.connection-string = mongodb://root:example@localhost:27017/
//application.properties
quarkus.mongodb.mongoClient1.connection-string = mongodb://root:example@localhost:27017/
Note that when using named clients, the "default" camelMongoClient
bean will still be produced. Refer to the Quarkus documentation on Multiple MongoDB Clients for more information.