当我们从更改源中的文档Db中获取数据时,我们只希望每个分区都尝试添加PatitionKey到代码中。基于分区的Azure更改源和查询
do
{
FeedResponse<PartitionKeyRange> pkRangesResponse = await client.ReadPartitionKeyRangeFeedAsync(
collectionUri,
new FeedOptions
{
RequestContinuation = pkRangesResponseContinuation,
PartitionKey = new PartitionKey("KEY"),
});
partitionKeyRanges.AddRange(pkRangesResponse);
pkRangesResponseContinuation = pkRangesResponse.ResponseContinuation;
}
while (pkRangesResponseContinuation != null);
它返回一个范围,当我们去进行第二次查询
IDocumentQuery<Document> query = client.CreateDocumentChangeFeedQuery(
collectionUri,
new ChangeFeedOptions
{
PartitionKeyRangeId = pkRange.Id,
StartFromBeginning = true,
RequestContinuation = continuation,
MaxItemCount = -1,
});
它返回所有来自所有分区的结果。有没有办法限制单个分区的结果?
根据这一[artilce](https://docs.microsoft.com/en-us/azure/cosmos-db/change-feed#a- idrest-with-the-rest-api-and-sdk),CreateDocumentChangeFeedQuery方法将从分区范围获得结果,我们不能仅仅限制单个分区的结果。 –
那么从这个建议,变更饲料只能通过中介服务器支持,而不是直接由客户支持?由于客户端可能无法访问其他分区数据? – user1932923
在我看来,中介服务器也是一个客户端。更改订阅源用于更改对Azure Cosmos DB数据所做的更改。 azure documentdb服务器仅支持分区范围跟踪。所以我们只能使用分区范围。 –