This commit is contained in:
Sidney Andrews 2022-09-27 11:31:18 -04:00 коммит произвёл GitHub
Родитель 7163f29259
Коммит 90e6285d7e
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 4AEE18F83AFDEB23
16 изменённых файлов: 98 добавлений и 254 удалений

Просмотреть файл

@ -1,8 +1,8 @@
# Cloud-Scale Data for Spring Developers Guide # Cloud-Scale Data for Spring Developers
> Java + Azure Cosmos DB + Azure Spring Apps + Azure Functions + Azure Cognitive Search + more! > Java + Azure Cosmos DB + Azure Spring Apps + Azure Functions + Azure Cognitive Search + more!
![Screenshot of book cover featuring title, an illustration of developer tools, the Azure Cosmos DB logo, a subtitle, and a version moniker. In this screenshot, the title is "Azure Cosmos DB Java Developers Guide", the subtitle is "Bring cloud-native Java applications to Azure using Azure Cosmos DB SQL API", and the version is "1.0".](docs/media/index/cover.svg) ![Screenshot of book cover featuring title, an illustration of developer tools, the Azure Cosmos DB logo, a subtitle, and a version moniker. In this screenshot, the title is "Cloud-Scale Data for Spring Developers", the subtitle is "Bring cloud-native Java applications to Azure using Azure Cosmos DB SQL API", and the version is "1.0".](docs/media/index/cover.svg)
[Get started reading the guide!](docs/index.md) [Get started reading the guide!](docs/index.md)
@ -24,4 +24,4 @@ contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additio
This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow [Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general). This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft trademarks or logos is subject to and must follow [Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship. Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
Any use of third-party trademarks or logos are subject to those third-party's policies. Any use of third-party trademarks or logos are subject to those third-party's policies.

Просмотреть файл

@ -55,11 +55,6 @@
<artifactId>azure-cosmos</artifactId> <artifactId>azure-cosmos</artifactId>
<version>4.22.0</version> <version>4.22.0</version>
</dependency> </dependency>
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>documentdb-bulkexecutor</artifactId>
<version>2.12.5</version>
</dependency>
<dependency> <dependency>
<groupId>org.springframework.boot</groupId> <groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-devtools</artifactId> <artifactId>spring-boot-devtools</artifactId>

Просмотреть файл

@ -14,9 +14,11 @@ import com.azure.spring.data.cosmos.core.ResponseDiagnostics;
import com.azure.spring.data.cosmos.core.ResponseDiagnosticsProcessor; import com.azure.spring.data.cosmos.core.ResponseDiagnosticsProcessor;
import com.azure.spring.data.cosmos.repository.config.EnableCosmosRepositories; import com.azure.spring.data.cosmos.repository.config.EnableCosmosRepositories;
import com.fasterxml.jackson.databind.JsonNode; import com.fasterxml.jackson.databind.JsonNode;
import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.context.annotation.Primary;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
@ -41,6 +43,12 @@ public class CosmosConfiguration extends AbstractCosmosConfiguration {
@Value("${azure.cosmos.lease-container}") @Value("${azure.cosmos.lease-container}")
private String leaseContainer; private String leaseContainer;
private CosmosAsyncClient client;
private CosmosAsyncDatabase database;
private CosmosAsyncContainer container;
private static final Logger logger = LoggerFactory.getLogger(CosmosConfiguration.class);
public CosmosConfiguration() {} public CosmosConfiguration() {}
@Bean @Bean
@ -73,6 +81,24 @@ public class CosmosConfiguration extends AbstractCosmosConfiguration {
}); });
} }
@Primary
@Bean
public CosmosAsyncClient getClient(){
return client = getCosmosClientBuilder().buildAsyncClient();
}
@Bean
public CosmosAsyncDatabase CosmosDatabaseBuilder() {
database = client.getDatabase(this.dbName);
return database;
}
@Bean
public CosmosAsyncContainer CosmosContainerBuilder() {
container = database.getContainer(this.feedContainer);
return container;
}
@Override @Override
public CosmosConfig cosmosConfig() { public CosmosConfig cosmosConfig() {
return CosmosConfig.builder() return CosmosConfig.builder()

Просмотреть файл

@ -1,75 +0,0 @@
package com.example.demo.config;
import com.microsoft.azure.documentdb.ConnectionPolicy;
import com.microsoft.azure.documentdb.ConsistencyLevel;
import com.microsoft.azure.documentdb.DocumentClient;
import com.microsoft.azure.documentdb.DocumentClientException;
import com.microsoft.azure.documentdb.DocumentCollection;
import com.microsoft.azure.documentdb.ResourceResponse;
import com.microsoft.azure.documentdb.bulkexecutor.DocumentBulkExecutor;
import com.microsoft.azure.documentdb.bulkexecutor.DocumentBulkExecutor.Builder;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
@Configuration
public class DocumentDbConfiguration {
private static final Logger LOGGER = LoggerFactory.getLogger(CosmosConfiguration.class);
@Value("${azure.cosmos.uri}")
private String uri;
@Value("${azure.cosmos.key}")
private String key;
@Value("${azure.cosmos.database}")
private String dbName;
@Value("${azure.cosmos.collection}")
private String collectionName;
@Value("${azure.cosmos.partitionKey}")
private String partitionKey;
@Bean
public DocumentClient getDocumentClient() {
ConnectionPolicy cPolicy = new ConnectionPolicy();
cPolicy.setMaxPoolSize(1000);
return new DocumentClient(uri, key, cPolicy, ConsistencyLevel.Session);
}
public static DocumentCollection getDocumentCollection(DocumentClient client, String databaseId, String collectionId) {
String collectionLink = String.format("/dbs/%s/colls/%s", databaseId, collectionId);
DocumentCollection collection = null;
try {
ResourceResponse<DocumentCollection> collectionResponse = client.readCollection(collectionLink, null);
collection = collectionResponse.getResource();
} catch (DocumentClientException dce) {
LOGGER.error("Error getting collection", dce);
}
return collection;
}
@Bean
public Builder getBulkExecutorBuilder() {
DocumentClient client = getDocumentClient();
client.getConnectionPolicy().getRetryOptions().setMaxRetryWaitTimeInSeconds(30);
client.getConnectionPolicy().getRetryOptions().setMaxRetryAttemptsOnThrottledRequests(9);
DocumentCollection collection = getDocumentCollection(client, dbName, collectionName);
return DocumentBulkExecutor.builder()
.from(
client,
dbName,
collection.getId(),
collection.getPartitionKey(),
1000
);
}
}

Просмотреть файл

@ -2,14 +2,9 @@ package com.example.demo.controller;
import java.util.List; import java.util.List;
import com.azure.cosmos.models.CosmosBulkItemResponse;
import com.example.demo.model.BaseModel; import com.example.demo.model.BaseModel;
import com.example.demo.model.BulkDeleteItem;
import com.example.demo.model.BulkUpdateItem;
import com.example.demo.service.BulkExecutorService; import com.example.demo.service.BulkExecutorService;
import com.microsoft.azure.documentdb.bulkexecutor.BulkDeleteResponse;
import com.microsoft.azure.documentdb.bulkexecutor.BulkImportResponse;
import com.microsoft.azure.documentdb.bulkexecutor.BulkUpdateResponse;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping; import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
@ -26,17 +21,17 @@ public class BulkController {
BulkExecutorService bulkExecutorService; BulkExecutorService bulkExecutorService;
@PostMapping(produces = "application/json", consumes = "application/json") @PostMapping(produces = "application/json", consumes = "application/json")
public BulkImportResponse create(@RequestBody List<BaseModel> documents) { public CosmosBulkItemResponse create(@RequestBody List<BaseModel> documents) {
return this.bulkExecutorService.bulkImport(documents); return this.bulkExecutorService.bulkImport(documents);
} }
@PutMapping(produces = "application/json", consumes = "application/json") @PutMapping(produces = "application/json", consumes = "application/json")
public BulkUpdateResponse update(@RequestBody List<BulkUpdateItem> updates) { public CosmosBulkItemResponse update(@RequestBody List<BaseModel> updates) {
return this.bulkExecutorService.bulkUpdate(updates); return this.bulkExecutorService.bulkUpdate(updates);
} }
@DeleteMapping(produces = "application/json", consumes = "application/json") @DeleteMapping(produces = "application/json", consumes = "application/json")
public BulkDeleteResponse delete(@RequestBody List<BulkDeleteItem> deleteItems){ public CosmosBulkItemResponse delete(@RequestBody List<BaseModel> deleteItems){
return this.bulkExecutorService.bulkDelete(deleteItems); return this.bulkExecutorService.bulkDelete(deleteItems);
} }
} }

Просмотреть файл

@ -1,15 +0,0 @@
package com.example.demo.model;
import org.apache.commons.lang3.tuple.Pair;
import lombok.*;
@Getter @Setter @NoArgsConstructor
public class BulkDeleteItem {
private String partitionKey;
private String id;
public Pair<String, String> toPair(){
return Pair.of(partitionKey, id);
}
}

Просмотреть файл

@ -1,24 +0,0 @@
package com.example.demo.model;
import java.util.List;
import java.util.stream.Collectors;
import com.microsoft.azure.documentdb.bulkexecutor.UpdateItem;
import com.microsoft.azure.documentdb.bulkexecutor.UpdateOperationBase;
import lombok.*;
@Getter @Setter @NoArgsConstructor
public class BulkUpdateItem {
private String id;
private String partitionKey;
private List<BulkUpdateOperation> operations;
public UpdateItem ToUpdateItem() {
List<UpdateOperationBase> updateOperations = operations.stream().map(BulkUpdateOperation::toUpdateOperation)
.collect(Collectors.toList());
return new UpdateItem(id, partitionKey, updateOperations);
}
}

Просмотреть файл

@ -1,22 +0,0 @@
package com.example.demo.model;
import com.microsoft.azure.documentdb.bulkexecutor.SetUpdateOperation;
import com.microsoft.azure.documentdb.bulkexecutor.internal.UpdateOperation;
import com.microsoft.azure.documentdb.bulkexecutor.internal.UpdateOperationType;
import lombok.*;
@Getter @Setter @NoArgsConstructor
public class BulkUpdateOperation {
private UpdateOperationType type;
private String field;
private Object value;
public UpdateOperation<Object> toUpdateOperation() {
//TODO define the UpdateOperationTypes so they implement the appropriate subclass
switch(type) {
default:
return new SetUpdateOperation<Object>(field, value);
}
}
}

Просмотреть файл

@ -1,48 +1,48 @@
package com.example.demo.service; package com.example.demo.service;
import java.util.List; import java.util.List;
import java.util.stream.Collectors;
import com.example.demo.model.BaseModel; import com.example.demo.model.BaseModel;
import com.example.demo.model.BulkDeleteItem;
import com.example.demo.model.BulkUpdateItem;
import com.fasterxml.jackson.core.JsonProcessingException; import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper; import com.fasterxml.jackson.databind.ObjectMapper;
import com.microsoft.azure.documentdb.bulkexecutor.BulkDeleteResponse;
import com.microsoft.azure.documentdb.bulkexecutor.BulkImportResponse;
import com.microsoft.azure.documentdb.bulkexecutor.BulkUpdateResponse;
import com.microsoft.azure.documentdb.bulkexecutor.DocumentBulkExecutor;
import com.microsoft.azure.documentdb.bulkexecutor.UpdateItem;
import com.microsoft.azure.documentdb.bulkexecutor.DocumentBulkExecutor.Builder;
import org.springframework.beans.factory.annotation.Autowired; import reactor.core.publisher.Flux;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.apache.commons.lang3.tuple.Pair;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import com.azure.cosmos.CosmosAsyncClient;
import com.azure.cosmos.CosmosAsyncContainer;
import com.azure.cosmos.CosmosAsyncDatabase;
import com.azure.cosmos.models.*;
@Component @Component
public class BulkExecutorService { public class BulkExecutorService {
private static final Logger LOGGER = LoggerFactory.getLogger(BulkExecutorService.class); private static final Logger LOGGER = LoggerFactory.getLogger(BulkExecutorService.class);
@Autowired CosmosAsyncClient client;
Builder builder; CosmosAsyncDatabase database;
CosmosAsyncContainer container;
@Autowired
ObjectMapper mapper; ObjectMapper mapper;
public BulkDeleteResponse bulkDelete(List<BulkDeleteItem> deleteItems) { //favouring constructor dependency injection
BulkDeleteResponse response = null; public BulkExecutorService(CosmosAsyncClient client, CosmosAsyncDatabase database, CosmosAsyncContainer container, ObjectMapper mapper){
try (DocumentBulkExecutor bExecutor = builder.build()) { this.client = client;
List<Pair<String, String>> pksAndIds = deleteItems.stream().map(BulkDeleteItem::toPair).collect(Collectors.toList()); this.database = database;
response = bExecutor.deleteAll(pksAndIds); this.container = container;
} catch (Exception ex) { this.mapper = mapper;
LOGGER.error("Error bulk deleting", ex);
}
return response;
} }
public CosmosBulkItemResponse bulkDelete(List<BaseModel> deleteItems) {
Flux<BaseModel> docs = Flux.fromIterable(deleteItems);
Flux<CosmosItemOperation> cosmosItemOperations = docs.map(
document -> CosmosBulkOperations
.getDeleteItemOperation(document.getId(), new PartitionKey(document.getDocumentType())));
return container.executeBulkOperations(cosmosItemOperations).blockLast().getResponse();
}
private String serialize(BaseModel model) { private String serialize(BaseModel model) {
String rawJson = null; String rawJson = null;
try { try {
@ -54,25 +54,17 @@ public class BulkExecutorService {
return rawJson; return rawJson;
} }
public BulkImportResponse bulkImport(List<BaseModel> documents) { public CosmosBulkItemResponse bulkImport(List<BaseModel> documents) {
BulkImportResponse response = null; Flux<BaseModel> docs = Flux.fromIterable(documents);
List<String> convertedDocuments = documents.stream().map(this::serialize).collect(Collectors.toList()); Flux<CosmosItemOperation> cosmosItemOperations = docs.map(
try (DocumentBulkExecutor bExecutor = builder.build()) { document -> CosmosBulkOperations.getUpsertItemOperation(document, new PartitionKey(document.getDocumentType())));
response = bExecutor.importAll(convertedDocuments, true, true, null); return container.executeBulkOperations(cosmosItemOperations).blockLast().getResponse();
} catch (Exception ex) {
LOGGER.error("Error bulk importing", ex);
}
return response;
} }
public BulkUpdateResponse bulkUpdate(List<BulkUpdateItem> updateItems) { public CosmosBulkItemResponse bulkUpdate(List<BaseModel> updateItems) {
BulkUpdateResponse response = null; Flux<BaseModel> docs = Flux.fromIterable(updateItems);
List<UpdateItem> updates = updateItems.stream().map(BulkUpdateItem::ToUpdateItem).collect(Collectors.toList()); Flux<CosmosItemOperation> cosmosItemOperations = docs.map(
try (DocumentBulkExecutor bExecutor = builder.build()) { document -> CosmosBulkOperations.getUpsertItemOperation(document, new PartitionKey(document.getDocumentType())));
response = bExecutor.updateAll(updates, null); return container.executeBulkOperations(cosmosItemOperations).blockLast().getResponse();
} catch (Exception ex) {
LOGGER.error("Error bulk updating", ex);
}
return response;
} }
} }

Просмотреть файл

@ -1,6 +1,6 @@
{ {
"info": { "info": {
"_postman_id": "83930195-5591-49b9-ab8f-fd8d6aeaaad7", "_postman_id": "3c5e7df1-124e-4450-bbd0-9bbcc15e0cf8",
"name": "Cosmosdb", "name": "Cosmosdb",
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json" "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
}, },
@ -15,7 +15,7 @@
"header": [], "header": [],
"body": { "body": {
"mode": "raw", "mode": "raw",
"raw": "{\r\n \"type\": \"test type\",\r\n \"name\": \"test name\",\r\n \"description\": \"test description\",\r\n \"manufacturerId\": \"test manufacturer\",\r\n \"msrp\": 10.00\r\n}", "raw": "{\r\n \"type\": \"test type\",\r\n \"documentType\": \"product\",\r\n \"name\": \"test name\",\r\n \"description\": \"test description\",\r\n \"manufacturerId\": \"test manufacturer\",\r\n \"msrp\": 10.00\r\n}",
"options": { "options": {
"raw": { "raw": {
"language": "json" "language": "json"
@ -612,7 +612,7 @@
"header": [], "header": [],
"body": { "body": {
"mode": "raw", "mode": "raw",
"raw": "[\n { \n \"partitionKey\":\"product\", \n \"id\": \"4e33d133-3490-4fe0-944a-cbffaab96ec2\" \n }\n]", "raw": "[\n {\n \"id\": \"1\",\n \"documentType\": \"product\"\n },\n {\n \"id\": \"2\",\n \"documentType\": \"customer\"\n },\n {\n \"id\": \"3\",\n \"documentType\": \"manufacturer\"\n }\n]",
"options": { "options": {
"raw": { "raw": {
"language": "json" "language": "json"
@ -641,7 +641,7 @@
"header": [], "header": [],
"body": { "body": {
"mode": "raw", "mode": "raw",
"raw": "[\n { \n \"documentType\": \"product\",\n \"type\": \"bulk product type\",\n \"name\": \"bulk product #1\",\n \"description\": \"products imported in bulk\",\n \"manufacturerId\": \"d73154c6-c657-4c81-b97a-756de35819ef\",\n \"msrp\": 100\n },\n {\n \"documentType\": \"customer\",\n \"firstName\": \"Bulk Customer\",\n \"lastName\": \"Number 1\",\n \"email\": \"customer@example.demo\"\n },\n {\n \"documentType\": \"manufacturer\",\n \"name\": \"bulk manufacturer #1\"\n }\n]", "raw": "[\n {\n \"id\": \"1\",\n \"documentType\": \"product\",\n \"type\": \"bulk product type\",\n \"name\": \"bulk product #1\",\n \"description\": \"products imported in bulk\",\n \"manufacturerId\": \"d73154c6-c657-4c81-b97a-756de35819ef\",\n \"msrp\": 100\n },\n {\n \"id\": \"2\",\n \"documentType\": \"customer\",\n \"firstName\": \"Bulk Customer\",\n \"lastName\": \"Number 1\",\n \"email\": \"customer@example.demo\"\n },\n {\n \"id\": \"3\",\n \"documentType\": \"manufacturer\",\n \"name\": \"bulk manufacturer #1\"\n }\n]",
"options": { "options": {
"raw": { "raw": {
"language": "json" "language": "json"
@ -670,7 +670,7 @@
"header": [], "header": [],
"body": { "body": {
"mode": "raw", "mode": "raw",
"raw": "[\n {\n \"id\": \"684a1471-4ec2-44cb-bc8b-0cc8604eed30\",\n \"partitionKey\": \"product\",\n \"operations\": [\n {\n \"type\": \"Set\",\n \"field\": \"name\",\n \"value\": \"derp\"\n }\n ]\n\n }\n]", "raw": "[\n {\n \"id\": \"1\",\n \"documentType\": \"product\",\n \"type\": \"bulk product type\",\n \"name\": \"bulk product #1\",\n \"description\": \"products bulk updated\",\n \"manufacturerId\": \"d73154c6-c657-4c81-b97a-756de35819ef\",\n \"msrp\": 100\n },\n {\n \"id\": \"2\",\n \"documentType\": \"customer\",\n \"firstName\": \"Bulk Update Customer\",\n \"lastName\": \"Number 1\",\n \"email\": \"customer@example.demo\"\n },\n {\n \"id\": \"3\",\n \"documentType\": \"manufacturer\",\n \"name\": \"bulk update manufacturer #1\"\n }\n]",
"options": { "options": {
"raw": { "raw": {
"language": "json" "language": "json"

Просмотреть файл

@ -1,6 +1,6 @@
theme: jekyll-theme-cayman theme: jekyll-theme-cayman
title: | title: |
Azure Cosmos DB Java Developer Guide Cloud-Scale Data for Spring Developers
description: | description: |
Java + Azure Cosmos DB + Azure Spring Apps + Azure Functions + Azure Cognitive Search + more! Java + Azure Cosmos DB + Azure Spring Apps + Azure Functions + Azure Cognitive Search + more!
exclude: exclude:

Просмотреть файл

@ -16,8 +16,7 @@ layout: default
<main> <main>
<article class="home mb-5 row"> <article class="home mb-5 row">
<aside class="col-sm-4"> <aside class="col-sm-4">
<img src="media/index/cover.svg" alt="Screenshot of book cover featuring title, an illustration of developer tools, the Azure Cosmos DB logo, a subtitle, and a version moniker. In this screenshot, the title is 'Azure Cosmos DB Java Developers Guide', the subtitle is 'Bring cloud-native Java applications to Azure using Azure Cosmos DB SQL API', and the version is '1.0'." /> <img src="media/index/cover.svg" alt="Screenshot of book cover featuring title, an illustration of developer tools, the Azure Cosmos DB logo, a subtitle, and a version moniker. In this screenshot, the title is 'Cloud-Scale Data for Spring Developers', the subtitle is 'Bring cloud-native Java applications to Azure using Azure Cosmos DB SQL API', and the version is '1.0'." /> </aside>
</aside>
<section class="col-sm-8"> <section class="col-sm-8">
{{ content }} {{ content }}
</section> </section>

Просмотреть файл

@ -10,29 +10,14 @@ ms.reviewer: mjbrown
sequence: 13 sequence: 13
--- ---
# Add the bulk executor feature # Bulk Execution
The bulk executor is an Azure Cosmos DB feature that allows bulk inserts, updates, and deletes. When inserts and updates occur, they appear in the change feed. Bulk Execution is an Azure Cosmos DB feature that allows bulk inserts, updates, and deletes. When inserts and updates occur, they appear in the change feed. Bulk Execution is part of the Java V4 SDK for Azure Cosmos DB.
The following sections incorporate the bulk executor into the code sample.
## Add a dependency
Add a new dependency in the *pom.xml* file:
```xml
<dependency>
<groupId>com.microsoft.azure</groupId>
<artifactId>documentdb-bulkexecutor</artifactId>
<version>2.12.5</version>
</dependency>
```
Add to the Spring Data setup by creating a `DocumentDbConfiguration` class specifically for use with the bulk executor.
## Add application properties ## Add application properties
Add bulk executer details to the *application-default.properties* file: Add details of the collection where bulk execution will be used to the *application-default.properties* file:
```properties ```properties
# values for bulk executor # values for bulk executor
@ -43,30 +28,18 @@ azure.cosmos.collectionThroughput = 100000;
## Update code ## Update code
Most of the bulk operations occur in `BulkExecutorService`. Each operation is in its own class file: All bulk operations occur in `BulkExecutorService`.
- `BulkUpdateOperation` A controller calls the bulk operations, with the following endpoints:
- `BulkDeleteItem` - `/api/bulk POST`: Bulk import
- `/api/bulk PUT`: Bulk update
- `/api/bulk DELETE`: Bulk delete
- `BulkUpdateItem` In the Postman collection, we've included a section for you to try each of these bulk operations against the sample code.
- `BulkExecutorService`
Update your code as follows:
1. Update your models to inherit from a `BaseModel` class.
1. Add a controller to call the bulk operations, with the following endpoints:
- `/api/bulk POST`: Bulk import
- `/api/bulk PUT`: Bulk update
- `/api/bulk DELETE`: Bulk delete
In the Postman collection, we've included a section for you to try each of these bulk operations against the sample code.
## Learn more ## Learn more
[Azure Cosmos DB bulk executor library overview](https://docs.microsoft.com/azure/cosmos-db/bulk-executor-overview) [Azure Cosmos DB bulk executor library overview](https://docs.microsoft.com/azure/cosmos-db/bulk-executor-overview)
[Next &#124; Schema design considerations](schema-considerations.md){: .btn .btn-primary .btn-lg } [Next &#124; Schema design considerations](schema-considerations.md){: .btn .btn-primary .btn-lg }

Просмотреть файл

@ -1,5 +1,5 @@
--- ---
title: Cloud-Scale Data for Spring Developers Guide title: Cloud-Scale Data for Spring Developers
description: Learn how the Cloud-Scale Data for Spring Developers Quick Start Guide can help you bring cloud-native Java applications to Azure. description: Learn how the Cloud-Scale Data for Spring Developers Quick Start Guide can help you bring cloud-native Java applications to Azure.
ms.service: cosmos-db ms.service: cosmos-db
ms.topic: reference ms.topic: reference
@ -10,9 +10,9 @@ ms.reviewer: mjbrown
sequence: 0 sequence: 0
--- ---
# Cloud-Scale Data for Spring Developers Guide: Foreword # Cloud-Scale Data for Spring Developers Quickstart guide: Foreword
Welcome to the Cloud-Scale Data for Spring Developers Developer Quick Start Guide. The purpose of this guide is to help you build cloud-native Java applications in Azure. You'll gain insights about using NoSQL and why you should consider Azure Cosmos DB, our fully managed, distributed NoSQL database service on Azure. Welcome to the Cloud-Scale for Spring Developers Quick Start Guide. The purpose of this guide is to help you build cloud-native Java applications in Azure. You'll gain insights about using NoSQL and why you should consider Azure Cosmos DB, our fully managed, distributed NoSQL database service on Azure.
These insights are designed to be useful whether you're starting with a NoSQL background or coming into a project with a relational mindset. Data isn't the only thing involved in an application, and this guide will take you through working with other Azure services that integrate well with Azure Cosmos DB. These insights are designed to be useful whether you're starting with a NoSQL background or coming into a project with a relational mindset. Data isn't the only thing involved in an application, and this guide will take you through working with other Azure services that integrate well with Azure Cosmos DB.
@ -28,7 +28,7 @@ Retail situations will be included, as well as suggestions for other business ca
## Not covered ## Not covered
This guide doesn't explain how to migrate existing Java applications to Azure. Migrating existing Java applications is covered in the [Java to Azure migration strategy documentation](/azure/developer/java/migration/). As well, this guide doesn't cover relational data storage in Azure. It isn't intended to be a complete compendium of all things Java and Azure, though there will be many Azure offerings showcased. This guide doesn't explain how to migrate existing Java applications to Azure. Migrating existing Java applications is covered in the [Java to Azure migration strategy documentation](/azure/developer/java/migration/). As well, this guide doesn't cover relational data storage in Azure. It isn't intended to be a complete compendium of all things Java and Azure, though there will be many Azure offerings showcased. The guide also does not offer a complete coverage of the Java SDK for Azure Cosmos DB, or the wider Java ecosystem for Azure Cosmos DB. It is not intended as a comprehensive recommendation for how to build *any* Java app using Azure Cosmos DB, but rather as a guide for how to get started with Spring Boot, featuring the `azure-spring-boot-starter-cosmos` library, as well as coverage of some core Java V4 SDK features and concepts.
## Scenario introduction ## Scenario introduction
@ -44,4 +44,4 @@ Start building your next Java app with Azure by taking advantage of the free app
* Azure Functions with up to 1M requests for free * Azure Functions with up to 1M requests for free
* Azure Cognitive Services up to 30,000 transactions free * Azure Cognitive Services up to 30,000 transactions free
[Next &#124; Introduction to NoSQL](intro-nosql.md){: .btn .btn-primary .btn-lg } [Next &#124; Introduction to NoSQL](intro-nosql.md){: .btn .btn-primary .btn-lg }

Просмотреть файл

@ -127,7 +127,7 @@ There are a few more things you need to set up before you can run your code:
### Clone the repository ### Clone the repository
Clone the repository that contains the sample code, which is available in the [Azure Cosmos DB Java Developer Guide repository](https://github.com/Azure/azure-cosmos-db-java-dev-guide/tree/main/demos). The repository contains a folder named *demos*, with the following contents: Clone the repository that contains the sample code, which is available in the [Cloud-Scale Data for Spring Developers repository](https://github.com/Azure/cloud-scale-for-spring-developer/tree/main/demos). The repository contains a folder named *demos*, with the following contents:
- hello-world-keyvault: An introduction to Java and Azure Key Vault, which is used to store your application secrets securely. - hello-world-keyvault: An introduction to Java and Azure Key Vault, which is used to store your application secrets securely.
@ -184,4 +184,4 @@ mvn spring-boot:run
- [Partition Strategy - Azure Cosmos DB Essentials, Season 2](https://www.youtube.com/watch?v=QLgK8yhKd5U) - [Partition Strategy - Azure Cosmos DB Essentials, Season 2](https://www.youtube.com/watch?v=QLgK8yhKd5U)
[Next &#124; Deploy to Azure App Service](deploy-to-azure-app-service.md){: .btn .btn-primary .btn-lg } [Next &#124; Deploy to Azure App Service](deploy-to-azure-app-service.md){: .btn .btn-primary .btn-lg }

Просмотреть файл

@ -1,6 +1,6 @@
--- ---
title: Cloud-Scale Data for Spring Developers Guide title: Cloud-Scale Data for Spring Developers
description: Cloud-Scale Data for Spring Developers is a quick start guide for bringing Cloud Native Java applications to Azure and using Azure Cosmos DB for your data needs. description: The Cloud-Scale Data for Spring Developers Quick Start Guide is a guide for bringing Cloud Native Java applications to Azure and using Azure Cosmos DB for your data needs.
ms.service: cosmos-db ms.service: cosmos-db
ms.topic: overview ms.topic: overview
ms.date: 08/19/2022 ms.date: 08/19/2022
@ -9,7 +9,7 @@ ms.author: sidandrews
ms.reviewer: mjbrown ms.reviewer: mjbrown
--- ---
# Cloud-Scale Data for Spring Developers Guide # Cloud-Scale Data for Spring Developers
## VERSION v1.0 ## VERSION v1.0
@ -35,4 +35,4 @@ Microsoft and the trademarks listed at <https://www.microsoft.com> on the "Trade
All other marks and logos are property of their respective owners. All other marks and logos are property of their respective owners.
[Next &#124; Foreword](foreword.md){: .btn .btn-primary .btn-lg } [Next &#124; Foreword](foreword.md){: .btn .btn-primary .btn-lg }