Azure-Samples / azure-cosmos-java-sql-api-samples

Sample code for Azure Cosmos DB Java SDK for SQL API
MIT License
38 stars 69 forks source link

Bulk operation is not working #69

Open mjaiswal17 opened 3 weeks ago

mjaiswal17 commented 3 weeks ago

` private void bulkCreateItems(List messages) {

    CosmosItemResponse cosmosItemResponse = container.createItem(messages.get(0));

    List<CosmosItemOperation> cosmosItemOperations = new ArrayList<>();
    for (Message message : messages) {
        cosmosItemOperations.add(CosmosBulkOperations.getCreateItemOperation(message, new PartitionKey(message.getEngagementId())));
    }

    Iterable<CosmosBulkOperationResponse<Message>> iterable = container.executeBulkOperations(cosmosItemOperations);

    }
    `

    Note:  CosmosItemResponse cosmosItemResponse = container.createItem(messages.get(0)); 
    is working and able to create the item in cosmos. Which means the container object is fine and working. It fails on the execute bulk operation part.

    Error:

    16:50:39.104 [bulk-executor-bounded-elastic-9] ERROR com.azure.cosmos.implementation.batch.BulkExecutor -- HandleTransactionalBatchOperationResult - Fail, PKRange 0, Response Status Code 200, Operation Status Code -1, ItemOperation[Type: CREATE, PK: ["c8ad54fb-043d-4749-911c-2846bbd8c081"], id: null], Context: BulkExecutor-1[n/a] Thread[Name: bulk-executor-bounded-elastic-9,Group: main, isDaemon: true, Id: 58]
mjaiswal17 commented 3 weeks ago

Env: Java 17 with Spring boot 3