camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From acosent...@apache.org
Subject [camel] 03/05: CAMEL-12302 : MongoDB - add documentation for new bulkWrite operation
Date Mon, 05 Mar 2018 07:20:27 GMT
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

commit d950dc69bfa8ef396df47163e319fb04aa9ce445
Author: Far├Ęs Hassak <fares.hassak@gmail.com>
AuthorDate: Sun Mar 4 21:21:06 2018 +0100

    CAMEL-12302 : MongoDB - add documentation for new bulkWrite operation
---
 .../src/main/docs/mongodb-component.adoc           | 37 ++++++++++++++++++++++
 .../src/main/docs/mongodb3-component.adoc          | 36 +++++++++++++++++++++
 2 files changed, 73 insertions(+)

diff --git a/components/camel-mongodb/src/main/docs/mongodb-component.adoc b/components/camel-mongodb/src/main/docs/mongodb-component.adoc
index e3dd18c..4406ce9 100644
--- a/components/camel-mongodb/src/main/docs/mongodb-component.adoc
+++ b/components/camel-mongodb/src/main/docs/mongodb-component.adoc
@@ -521,6 +521,43 @@ A header with key `CamelMongoDbRecordsAffected` is returned
 containing the number of records deleted (copied from
 `WriteResult.getN()`).
 
+
+==== Bulk Write Operations
+
+===== bulkWrite
+
+*Available as of Camel 2.21*
+
+Performs write operations in bulk with controls for order of execution.
+Requires a `List<WriteModel<DBObject>>` as the IN message body containing commands
for insert, update, and delete operations.
+
+The following example will insert a new scientist "Pierre Curie", update record with id "5"
by setting the value of the "scientist" field to
+"Marie Curie" and delete record with id "3" :
+
+[source,java]
+------------------------------------------------------------------------------------------------------------------
+// route: from("direct:bulkWrite").to("mongodb:myDb?database=science&collection=notableScientists&operation=bulkWrite");
+List<WriteModel<DBObject>> bulkOperations = Arrays.asList(
+            new InsertOneModel<>(new BasicDBObject("scientist", "Pierre Curie")),
+            new UpdateOneModel<>(new BasicDBObject("_id", "5"), 
+                                 new BasicDBObject("$set", new BasicDBObject("scientist",
"Marie Curie"))),
+            new DeleteOneModel<>(new BasicDBObject("_id", "3")));
+
+BulkWriteResult result = template.requestBody("direct:bulkWrite", bulkOperations, BulkWriteResult.class);
+------------------------------------------------------------------------------------------------------------------
+
+By default, operations are executed in order and interrupted on the first write error without
processing any remaining write operations in the list.
+To instruct MongoDB to continue to process remaining write operations in the list, set the
`CamelMongoDbBulkOrdered` IN message header to `false`. 
+Unordered operations are executed in parallel and this behavior is not guaranteed.
+
+[width="100%",cols="10%,10%,10%,70%",options="header",]
+|=======================================================================
+|Header key |Quick constant |Description (extracted from MongoDB API doc) |Expected type
+
+|`CamelMongoDbBulkOrdered` |`MongoDbConstants.BULK_ORDERED` | Perform an ordered or unordered
operation execution. Defaults to true. |boolean/Boolean
+|=======================================================================
+
+
 ==== Other operations
 
 ===== aggregate
diff --git a/components/camel-mongodb3/src/main/docs/mongodb3-component.adoc b/components/camel-mongodb3/src/main/docs/mongodb3-component.adoc
index 3351340..ceae01a 100644
--- a/components/camel-mongodb3/src/main/docs/mongodb3-component.adoc
+++ b/components/camel-mongodb3/src/main/docs/mongodb3-component.adoc
@@ -569,6 +569,42 @@ A header with key `CamelMongoDbRecordsAffected` is returned
 containing the number of records deleted (copied from
 `WriteResult.getN()`).
 
+==== Bulk Write Operations
+
+===== bulkWrite
+
+*Available as of Camel 2.21*
+
+Performs write operations in bulk with controls for order of execution.
+Requires a `List<WriteModel<DBObject>>` as the IN message body containing commands
for insert, update, and delete operations.
+
+The following example will insert a new scientist "Pierre Curie", update record with id "5"
by setting the value of the "scientist" field to
+"Marie Curie" and delete record with id "3" :
+
+[source,java]
+------------------------------------------------------------------------------------------------------------------
+// route: from("direct:bulkWrite").to("mongodb:myDb?database=science&collection=notableScientists&operation=bulkWrite");
+List<WriteModel<Document>> bulkOperations = Arrays.asList(
+            new InsertOneModel<>(new Document("scientist", "Pierre Curie")),
+            new UpdateOneModel<>(new Document("_id", "5"), 
+                                 new Document("$set", new Document("scientist", "Marie Curie"))),
+            new DeleteOneModel<>(new Document("_id", "3")));
+
+BulkWriteResult result = template.requestBody("direct:bulkWrite", bulkOperations, BulkWriteResult.class);
+------------------------------------------------------------------------------------------------------------------
+
+By default, operations are executed in order and interrupted on the first write error without
processing any remaining write operations in the list.
+To instruct MongoDB to continue to process remaining write operations in the list, set the
`CamelMongoDbBulkOrdered` IN message header to `false`. 
+Unordered operations are executed in parallel and this behavior is not guaranteed.
+
+[width="100%",cols="10%,10%,10%,70%",options="header",]
+|=======================================================================
+|Header key |Quick constant |Description (extracted from MongoDB API doc) |Expected type
+
+|`CamelMongoDbBulkOrdered` |`MongoDbConstants.BULK_ORDERED` | Perform an ordered or unordered
operation execution. Defaults to true. |boolean/Boolean
+|=======================================================================
+
+
 ==== Other operations
 
 ===== aggregate

-- 
To stop receiving notification emails like this one, please contact
acosentino@apache.org.

Mime
View raw message