ChangeFeed - 上次成功的操作已处理
ChangeFeed - Last Successful Operation Processed
下面的代码片段遍历更改源。如果我们需要跟踪最后一条成功处理的记录,就是循环中continuation加上index(continuation + i)计算出来的and/or文档的ETag。如果出现故障,我如何从那个确切的地方查询更改提要?不清楚,因为当我从 0 开始并请求 1000 时,我测试中的延续令牌是 1120。
IDocumentQuery < Document > query = client.CreateDocumentChangeFeedQuery(
collectionUri,
new ChangeFeedOptions {
PartitionKeyRangeId = pkRange.Id,
StartFromBeginning = true,
RequestContinuation = continuation,
MaxItemCount = 1000
});
while (query.HasMoreResults) {
Dictionary < string, BlastTimeRange > br = new Dictionary < string, BlastTimeRange > ();
var readChangesResponse = query.ExecuteNextAsync < Document > ().Result;
int i =0;
foreach(Document changedDocument in readChangesResponse.AsEnumerable().ToList()) {
// processing each one
// the continuation and i represent the place or is it better to store off the ETag?
}
}
今天执行此操作的最佳方法是跟踪延续标记(与 REST API 中的 ETag
相同),以及您创建的文档的 _rid
值列表在批次内阅读。读取下一批时,必须排除之前处理过的_rid
个值。
无需编写自定义代码即可执行此操作的最简单方法是使用 DocumentDB 团队的 ChangeFeedProcessor 库(预览版)。为了获得访问权限。请发邮件至 askdocdb@microsoft.com.
下面的代码片段遍历更改源。如果我们需要跟踪最后一条成功处理的记录,就是循环中continuation加上index(continuation + i)计算出来的and/or文档的ETag。如果出现故障,我如何从那个确切的地方查询更改提要?不清楚,因为当我从 0 开始并请求 1000 时,我测试中的延续令牌是 1120。
IDocumentQuery < Document > query = client.CreateDocumentChangeFeedQuery(
collectionUri,
new ChangeFeedOptions {
PartitionKeyRangeId = pkRange.Id,
StartFromBeginning = true,
RequestContinuation = continuation,
MaxItemCount = 1000
});
while (query.HasMoreResults) {
Dictionary < string, BlastTimeRange > br = new Dictionary < string, BlastTimeRange > ();
var readChangesResponse = query.ExecuteNextAsync < Document > ().Result;
int i =0;
foreach(Document changedDocument in readChangesResponse.AsEnumerable().ToList()) {
// processing each one
// the continuation and i represent the place or is it better to store off the ETag?
}
}
今天执行此操作的最佳方法是跟踪延续标记(与 REST API 中的 ETag
相同),以及您创建的文档的 _rid
值列表在批次内阅读。读取下一批时,必须排除之前处理过的_rid
个值。
无需编写自定义代码即可执行此操作的最简单方法是使用 DocumentDB 团队的 ChangeFeedProcessor 库(预览版)。为了获得访问权限。请发邮件至 askdocdb@microsoft.com.