1

我正在尝试按照以下代码从 Cosmos db Change Feed 中的受监控 Db 中获取所有更改。我正在尝试不同的持续时间,例如今天发生的变化或过去 7 天发生的变化或整体发生的变化。现在在所有情况下,我在第一次获得所有更改,而在第二次运行中没有任何更改,除非有更改即将到来。我想知道我在这里做错了什么,如果我每次运行都必须在上周进行更改,如果我的以下代码不正确,我应该如何配置更改提要。提前致谢

 private static CosmosClient Client { get; set; }
    static void Main(string[] args)
    {
        Task.Run(async () =>
        {
            Client = new CosmosClient("AccountEndpoint = https://test.documents.azure.com:443/;AccountKey=FW5yvDA==;");
            var database = Client.GetDatabase("twstDatabase");
            var container = database.GetContainer("TestContainer");
            var leaseContainer = database.GetContainer("leases");

            var cfp = container.GetChangeFeedProcessorBuilder<dynamic>("cfpLibraryDThird", ProcessChanges)
                .WithLeaseContainer(leaseContainer)
                .WithInstanceName("Change Feed Instance Demo") 
// I change the instance name for different start time
                    .WithStartTime(DateTime.Today.AddDays(-7).ToUniversalTime())
                    //.WithStartTime(DateTime.MinValue.ToUniversalTime())
                    .Build();
                await cfp.StartAsync();
                Console.WriteLine("Started Change feed processor- press key to stop");
                Console.ReadKey(true);
                await cfp.StopAsync();
            }).Wait();
        }

        static async Task ProcessChanges(IReadOnlyCollection<dynamic> docs, CancellationToken cancellationToken)
        {
            foreach (var doc in docs)
            {
                Console.WriteLine($"Document {doc.id} has changed");
                
            }
        }
    }
}
4

2 回答 2

0

这是 3.15 的错误,您可以在此处跟踪此问题https://github.com/Azure/azure-cosmos-dotnet-v3/issues/2031

于 2020-12-02T05:45:35.953 回答
0

它被固定在 3.15.1。我更新了软件包,它解决了问题。

于 2020-12-28T13:37:13.633 回答