【问题标题】:Read EventHub data from specified time从指定时间读取 EventHub 数据
【发布时间】:2016-10-13 06:22:46
【问题描述】:

我有一个正在运行的 EvenHub,它被 Windows 服务监听。意外地,WindowsService 停止工作 2 天。如何从 EventHub 停止的地方读取数据?我的 OffSet 设置如下所示:

processorOptions.InitialOffsetProvider = (partionId) => DateTime.UtcNow;

我尝试再次启动windows服务,但它从现在开始。

对此有什么想法吗?

【问题讨论】:

    标签: azure azure-storage azure-web-app-service azure-eventhub


    【解决方案1】:

    您是否曾经在您的EventProcessor 中调用await context.CheckpointAsync();?否则,您将无法轻松做到这一点。通常EventProcessor 会跟踪已处理的项目。您可以在一段时间后或在您的EventProcessor 处理了许多项目之后调用await context.CheckpointAsync();

    使用

    processorOptions.InitialOffsetProvider = (partionId) => DateTime.UtcNow;
    

    您基本上是告诉EventProcessor 忽略之前到达的所有物品。那不是你需要的。删除此调用,如果您在处理代码中调用了await context.CheckpointAsync();,它将继续处理尚未处理的项目。如果没有可用的检查点,它将从流的开头开始,具体取决于配置的保留。然后,您将不得不手动跳过您可能已经处理过的项目。

    一些背景阅读:

    understanding check pointing in eventhub

    https://blogs.msdn.microsoft.com/servicebus/2015/01/16/event-processor-host-best-practices-part-1/

    http://blogs.biztalk360.com/understanding-consumer-side-of-azure-event-hubs-checkpoint-initialoffset-eventprocessorhost/

    【讨论】:

    • '等待上下文.CheckpointAsync();'用特定的时间量定义。我通过你提供的线索解决了这个问题。现在设置自定义 DateTime 而不是 Utc Date。谢谢彼得.. :)
    猜你喜欢
    • 2020-06-28
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-01-23
    • 2022-01-12
    • 2022-10-21
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多