You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by GitBox <gi...@apache.org> on 2022/12/01 10:09:20 UTC

[GitHub] [camel-karaf] essobedo commented on pull request #217: CAMEL-18781: Re-add the camel-mongodb and camel-mongodb-gridfs features

essobedo commented on PR #217:
URL: https://github.com/apache/camel-karaf/pull/217#issuecomment-1333524578

   Tested successfully with the next routes:
   ```
   <blueprint xmlns="http://www.osgi.org/xmlns/blueprint/v1.0.0"
              xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
              xmlns:cm="http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0"
              xsi:schemaLocation="
                http://aries.apache.org/blueprint/xmlns/blueprint-cm/v1.1.0 http://aries.apache.org/schemas/blueprint-cm/blueprint-cm-1.1.0.xsd
                http://www.osgi.org/xmlns/blueprint/v1.0.0 https://www.osgi.org/xmlns/blueprint/v1.0.0/blueprint.xsd">
   
       <!-- blueprint property placeholders, that will use etc/mongodb.cfg as the properties file -->
       <cm:property-placeholder persistent-id="mongodb" update-strategy="reload">
   
       </cm:property-placeholder>
   
       <bean id="myDb" class="com.mongodb.client.MongoClients" factory-method="create">
           <argument value="mongodb://localhost:27017" />
       </bean>
       <bean id="mongodb" class="org.apache.camel.component.mongodb.MongoDbComponent">
           <property name="mongoConnection" ref="myDb"/>
       </bean>
   
       <camelContext xmlns="http://camel.apache.org/schema/blueprint">
           <route>
               <from uri="timer:myTimer?period=5000" />
               <setBody><simple>{"_id": "someDocId${header.firedTime}", "a" : 1, "b" : 2}</simple></setBody>
               <to uri="mongodb:myDb?database={{mongodb.testDb}}&amp;collection={{mongodb.testCollection}}&amp;operation=insert" /> <!-- &amp;writeConcern=SAFE" /> -->
               <log message="Insert doc: ${body}"/>
               <setBody><simple>someDocId${header.firedTime}</simple></setBody>
               <to uri="mongodb:myDb?database={{mongodb.testDb}}&amp;collection={{mongodb.testCollection}}&amp;operation=findById" />
               <log message="Get doc: ${body}"/>
               <setHeader name="CamelMongoDbCriteria"><simple>{ "_id": "someDocId${header.firedTime}" }</simple></setHeader>
               <setBody><constant>{"$set": {"a": "2"}}</constant></setBody>
               <to uri="mongodb:myDb?database={{mongodb.testDb}}&amp;collection={{mongodb.testCollection}}&amp;operation=update" /> <!-- &amp;writeConcern=SAFE" /> -->
               <log message="Update doc: ${body}"/>
               <setBody><simple>someDocId${header.firedTime}</simple></setBody>
               <to uri="mongodb:myDb?database={{mongodb.testDb}}&amp;collection={{mongodb.testCollection}}&amp;operation=findById" />
               <log message="Get doc: ${body}"/>
               <setBody><simple>{ "_id": "someDocId${header.firedTime}" }</simple></setBody>
               <to uri="mongodb:myDb?database={{mongodb.testDb}}&amp;collection={{mongodb.testCollection}}&amp;operation=remove" />
               <log message="Delete doc: ${body}"/>
           </route>
           <route>
               <from uri="mongodb:myDb?consumerType=changeStreams&amp;database={{mongodb.testDb}}&amp;collection={{mongodb.testCollectionConsumer}}" />
               <log message="Change received: ${body}"/>
           </route>        
           <route>
               <from uri="timer:myTimerConsumer?period=5000" />
               <setBody><simple>{"scientist" : "Einstein", "date" : "${header.firedTime}"}</simple></setBody>
               <to uri="mongodb:myDb?database={{mongodb.testDb}}&amp;collection={{mongodb.testCollectionConsumer}}&amp;operation=insert" />
               <log message="Insert doc: ${body}"/>
           </route>
           <route>
               <from uri="timer:myTimerFS?period=5000" />
               <setHeader name="CamelFileName"><simple>SomeFile${header.firedTime}</simple></setHeader>
               <setBody><simple>Hello MongoDB GridFS at ${header.firedTime}</simple></setBody>
               <to uri="mongodb-gridfs:myDb?database={{mongodb.testDb}}&amp;operation=create" /> <!-- &amp;writeConcern=SAFE" /> -->
               <log message="Insert file: ${body}"/>
               <to uri="mongodb-gridfs:myDb?database={{mongodb.testDb}}&amp;operation=findOne" />
               <log message="Find file: ${body}"/>
               <to uri="mongodb-gridfs:myDb?database={{mongodb.testDb}}&amp;operation=listAll" />
               <log message="List all: ${body}"/>
               <to uri="mongodb-gridfs:myDb?database={{mongodb.testDb}}&amp;operation=count" />
               <log message="Count: ${body}"/>
               <delay><constant>2000</constant></delay>
               <to uri="mongodb-gridfs:myDb?database={{mongodb.testDb}}&amp;operation=remove" />
               <log message="Remove file: ${body}"/>
           </route>
           <route>
           	<from uri="mongodb-gridfs:myDb?database={{mongodb.testDb}}&amp;queryStrategy=TimeStampAndFileAttribute&amp;query={'filename': { $regex : /^SomeFile/ }\}" />
               <log message="File received: ${body}"/>
           </route>      
       </camelContext>
   
   </blueprint>
   
   ```


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscribe@camel.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org