You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ac...@apache.org on 2018/10/10 08:28:16 UTC

[camel] branch master updated: mongodb3 - adds example of iterating over a DBCursor (#2560)

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

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


The following commit(s) were added to refs/heads/master by this push:
     new a4bcfe8  mongodb3 - adds example of iterating over a DBCursor (#2560)
a4bcfe8 is described below

commit a4bcfe8993d257b7e6543e109ae0fbba2806f6fb
Author: Peter Nagy <xi...@gmail.com>
AuthorDate: Wed Oct 10 10:28:09 2018 +0200

    mongodb3 - adds example of iterating over a DBCursor (#2560)
---
 .../src/main/docs/mongodb3-component.adoc               | 17 +++++++++++++++--
 1 file changed, 15 insertions(+), 2 deletions(-)

diff --git a/components/camel-mongodb3/src/main/docs/mongodb3-component.adoc b/components/camel-mongodb3/src/main/docs/mongodb3-component.adoc
index 09313ce..a34daf2 100644
--- a/components/camel-mongodb3/src/main/docs/mongodb3-component.adoc
+++ b/components/camel-mongodb3/src/main/docs/mongodb3-component.adoc
@@ -670,8 +670,7 @@ Example with option outputType=MongoIterable and batch size:
 
 [source,java]
 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
-// route: from("direct:aggregate").to("mongodb3:myDb?database=science&collection=notableScientists&operation=aggregate&outputType=MongoIterable");
-List<Bson> aggregate = Arrays.asList(match(or(eq("scientist", "Darwin"), eq("scientist", 
+List<Bson> aggregate = Arrays.asList(match(or(eq("scientist", "Darwin"), eq("scientist",
         group("$scientist", sum("count", 1)));
 from("direct:aggregate")
     .setHeader(MongoDbConstants.BATCH_SIZE).constant(10)
@@ -680,6 +679,20 @@ from("direct:aggregate")
     .to("mock:resultAggregate");
 ----------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
+Example with outputType=DBCursor and batch size showing how to iterate over the cursor's data:
+
+[source,java]
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------
+List<Bson> aggregate = Arrays.asList(match(or(eq("scientist", "Darwin"), eq("scientist",
+        group("$scientist", sum("count", 1)));
+from("direct:aggregate")
+    .setHeader(MongoDbConstants.BATCH_SIZE).constant(10)
+    .setBody().constant(aggregate)
+    .to("mongodb3:myDb?database=science&collection=notableScientists&operation=aggregate&outputType=MongoIterable")
+    .split(body())
+    .streaming()
+    .to("mock:resultAggregate");
+----------------------------------------------------------------------------------------------------------------------------------------------------------------------
 
 ===== getDbStats