What DBCollection WriteConcern suits for this operation
I am using MonogoDB in my application .
I am performing a big insert operation for all the symbols present in the
arraylist as shown below
I am afraid that while this insertion is big , it may block another
operations , is there anyway that i can tell MongoDB that perform this
insert operation in background (that is asynchronosly ) means dont let
other executions stop for this .
Is this possible to do ??
public void insert(ArrayList<QuoteReportBean> quotelist)
{
BasicDBList totalrecords = new BasicDBList();
for (QuoteReportBean reportbean: quotelist) {
BasicDBObject dbrecord = new BasicDBObject();
dbrecord.append("custid", reportbean.getCustomerId());
dbrecord.append("symbol", reportbean.getUniqueSymbol());
dbrecord.append("exch", reportbean.getExchange());
totalrecords.add(dbrecord);
}
WriteResult result = coll.insert(totalrecords);
logger.error(" - " + result.toString());
}
my requiremnt is that this opeartion should be completed , but at the same
time this should not block other operations . I have seen the WriteConcern
can improve perfromance in this case .
WriteConcern.NONE No exceptions are raised, even for network issues.
WriteConcern.NORMAL Write operations that use this write concern will
return as soon as the message is written to the socket.
WriteConcern.UNACKNOWLEDGED Write operations that use this write concern
will return as soon as the message is written to the socket.
collected from
http://api.mongodb.org/java/current/com/mongodb/WriteConcern.html
I am planning to use WriteConcern.UNACKNOWLEDGED , please let me know if
this is best or are there any isssues i need to take care of
Or is there any other way for completing it asynchonously
please share your ideas . Thank you very much in advance .
No comments:
Post a Comment