简体   繁体   中英

Azure Cosmos: changeFeedProcessor: Error: PartitionKey value must be supplied for this operation

I am trying the sample application for changeFeedProcessor SDK for Azure-Cosmos.

GIT link of repo: https://github.com/Azure/azure-documentdb-changefeedprocessor-java

have configured all the required properties as below

COSMOSDB_ENDPOINT={hostandport}

COSMOSDB_SECRET={secretKey}

COSMOSDB_DATABASE={DBName}

COSMOSDB_COLLECTION={CollectionName}

COSMOSDB_AUX_COLLECTION={AuxCollectionName}

COSMOSDB_LEASE_COLLECTION={LeaseCollectionName}

and provided the hostname in sample.java

In the method DocumentLeaseServiceManager.initialize(), documentServices.createDocument() operation is success, while documentServices.deleteDocument() fails with the below error

java.lang.UnsupportedOperationException: PartitionKey value must be supplied for this operation. at com.microsoft.azure.documentdb.DocumentClient.addPartitionKeyInformation(DocumentClient.java:3346) at com.microsoft.azure.documentdb.DocumentClient.deleteDocument(DocumentClient.java:1047) at com.microsoft.azure.documentdb.changefeedprocessor.services.DocumentServices.deleteDocument(DocumentServices.java:248) at com.microsoft.azure.documentdb.changefeedprocessor.internal.documentleasestore.DocumentServiceLeaseManager.initialize(DocumentServiceLeaseManager.java:116) at com.microsoft.azure.documentdb.changefeedprocessor.ChangeFeedEventHost.initializeIntegrations(ChangeFeed EventHost.java:165) at com.microsoft.azure.documentdb.changefeedprocessor.ChangeFeedEventHost.start(ChangeFeedEventHost.java:143) at com.microsoft.azure.documentdb.changefeedprocessor.ChangeFeedEventHost.lambda$registerObserverFactory$0(ChangeFeedEventHost.java:133) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) at java.lang.Thread.run(Thread.java:748)

Would really appreciate a solution.

That version of the Change Feed Processor seems rather old. It could be possible that is not compatible with partitioned Lease containers. If your Lease collection is partitioned (Partition Key should be /id ), try the updated Change Feed Processor that is already part of the Java SDK.

Reference: https://github.com/Azure/azure-cosmosdb-java/tree/v3

Example: https://github.com/Azure/azure-cosmosdb-java/tree/v3/examples/src/main/java/com/azure/data/cosmos/examples/ChangeFeed

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM