You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@camel.apache.org by "Andrea Cosentino (JIRA)" <ji...@apache.org> on 2018/03/05 07:23:00 UTC
[jira] [Updated] (CAMEL-12302) camel-mongodb : Support for bulk
writes operation
[ https://issues.apache.org/jira/browse/CAMEL-12302?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ]
Andrea Cosentino updated CAMEL-12302:
-------------------------------------
Fix Version/s: 2.21.0
> 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
> Assignee: Andrea Cosentino
> Priority: Major
> Fix For: 2.21.0
>
>
> 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)