[
https://issues.apache.org/jira/browse/CAMEL-12302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16385373#comment-16385373
]
ASF GitHub Bot commented on CAMEL-12302:
----------------------------------------
GitHub user fhassak opened a pull request:
https://github.com/apache/camel/pull/2244
CAMEL-12302 : MongoDB - add bulk writes operation
Hello,
New builk write operation !
Thanks to @csarrazi
You can merge this pull request into a Git repository by running:
$ git pull https://github.com/fhassak/camel CAMEL-12302
Alternatively you can review and apply these changes as the patch at:
https://github.com/apache/camel/pull/2244.patch
To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:
This closes #2244
----
commit 18e85587c3936fa3c6194479292be42f893f2b03
Author: Farès Hassak <fares.hassak@...>
Date: 2018-02-28T21:23:53Z
CAMEL-12302 : add bulk writes operation
commit 93bd44dd8b1f8e30ebb7d4afc2424ddea052ebce
Author: Farès Hassak <fares.hassak@...>
Date: 2018-03-04T14:38:37Z
CAMEL-12302 : MongoDB3 - add bulk writes operation
commit adf28395be2b843ca85b76af4b74fcd3149ba651
Author: Farès Hassak <fares.hassak@...>
Date: 2018-03-04T20:21:06Z
CAMEL-12302 : MongoDB - add documentation for new bulkWrite operation
----
> camel-mongodb : Support for bulk writes operation
> -------------------------------------------------
>
> Key: CAMEL-12302
> URL: https://issues.apache.org/jira/browse/CAMEL-12302
> Project: Camel
> Issue Type: New Feature
> Components: camel-mongodb, camel-mongodb3
> Reporter: Farès Hassak
> Priority: Major
>
> Hello,
> To improve write performance, we need support for bulk operations :
> [https://mongodb.github.io/mongo-java-driver/3.6/driver/tutorials/bulk-writes/]
> [https://docs.mongodb.com/manual/core/bulk-write-operations/]
> I will add new bulkWrite operation that expect a list of WriteModel Object in
> body.
> Example :
> {code: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",
> "Descartes")),
> 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", "2")));
> BulkWriteResult result = template.requestBody("direct:bulkWrite",
> bulkOperations, BulkWriteResult.class);
> {code}
>
> An header with key CamelMongoDbBulkOrdered will be added (true is the default
> value).
> {code:java}
> BulkWriteResult result = template.requestBodyAndHeader("direct:bulkWrite",
> bulkOperations, MongoDbConstants.BULK_ORDERED, false, BulkWriteResult.class)
> {code}
> Later, i will add support for String :
> {code:java}
> // route:
> from("direct:bulk").to("mongodb:myDb?database=science&collection=notableScientists&operation=bulkWrite");
> template.requestBody("direct:bulkWrite", "[
> { \"insertOne\" : { \"document\" : { \"scientist\" : \"Descartes\" }}},
> { \"insertOne\" : { \"document\" : { \"scientist\" : \"Pierre Curie\" }}},
> { \"updateOne\" : { \"filter\" : { \"_id\" : \"5\" }, \"update\" : {
> \"$set\" : { \"scientist\" : \"Marie Curie\" }}}},
> { \"deleteOne\" : { \"filter\" : { \"_id\" : 2} }} ]");
> {code}
> I will do 2 PR.
> Farès
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)