bulkimport/src/main/java/com/microsoft/azure/documentdb/bulkimport/DocumentBulkImporter.java
public BulkImportResponse importAll(Collection<String> documents, boolean isUpsert) throws DocumentClientException {
        return executeBulkImportInternal(documents,
                isUpsert);
    }
public BulkImportResponse importAll(Collection<String> documents, boolean isUpsert) throws DocumentClientException {
        return executeBulkImportInternal(documents,
                isUpsert);
    }
public BulkImportResponse importAll ( Collection < String > documents , boolean isUpsert ) throws DocumentClientException { return executeBulkImportInternal ( documents , isUpsert ) ; }
Executes a bulk import in the Azure Cosmos DB database service.
<blockquote>
<pre>
{@code
ConnectionPolicy connectionPolicy = new ConnectionPolicy();
RetryOptions retryOptions = new RetryOptions();
// set to 0 to let bulk importer handles throttling
retryOptions.setMaxRetryAttemptsOnThrottledRequests(0);
connectionPolicy.setRetryOptions(retryOptions);
connectionPolicy.setMaxPoolSize(200);

DocumentClient client = new DocumentClient(HOST, MASTER_KEY, connectionPolicy, null);

String collectionLink = String.format("/dbs/%s/colls/%s", "mydb", "mycol");
DocumentCollection collection = client.readCollection(collectionLink, null).getResource();

DocumentBulkImporter importer = DocumentBulkImporter.builder().from(client, collection).build();

for(int i = 0; i < 10; i++) {
List<String> documents = documentSource.getMoreDocuments();

BulkImportResponse bulkImportResponse = importer.importAll(documents, false);

//validate that all documents inserted to ensure no failure.
// bulkImportResponse.getNumberOfDocumentsImported() == documents.size()
if (bulkImportResponse.getNumberOfDocumentsImported() < documents.size()) {
for(Exception e: bulkImportResponse.getFailuresIfAny()) {
// validate why there were some failures
// in case if you decide to re-import these batch of documents
// (as some of them may already have inserted)
// you should import them with upsert enable option
e.printStackTrace();
}
break;
}
}

importer.close();
client.close();
}
</pre>
</blockquote>

@param documents to insert
@param isUpsert whether enable upsert (overwrite if it exists)
@return an instance of {@link BulkImportResponse}
@throws DocumentClientException if any failure happens
Executes a bulk import in the Azure Cosmos DB database service . <blockquote > <pre > { @code ConnectionPolicy connectionPolicy = new ConnectionPolicy () ; RetryOptions retryOptions = new RetryOptions () ; // set to 0 to let bulk importer handles throttling retryOptions . setMaxRetryAttemptsOnThrottledRequests ( 0 ) ; connectionPolicy . setRetryOptions ( retryOptions ) ; connectionPolicy . setMaxPoolSize ( 200 ) ;