[ 
https://issues.apache.org/jira/browse/CAMEL-12302?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16385820#comment-16385820
 ] 

ASF GitHub Bot commented on CAMEL-12302:
----------------------------------------

oscerd commented on issue #2244:  CAMEL-12302 : MongoDB - add bulk writes 
operation
URL: https://github.com/apache/camel/pull/2244#issuecomment-370351288
 
 
   Yeah, sorry

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
[email protected]


> 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)

Reply via email to