Event Hub处理器 - 如何在本地开发框中模拟closereason.shutdown

时间:2016-11-23 02:35:09

标签: azure azure-eventhub

我将Event Hub示例代码复制到我的事件处理器项目:

  async Task IEventProcessor.CloseAsync(PartitionContext context, CloseReason reason)
{
    Console.WriteLine("Processor Shutting Down. Partition '{0}', Reason: '{1}'.", context.Lease.PartitionId, reason);
    if (reason == CloseReason.Shutdown)
    {
    await context.CheckpointAsync();
    }
}

我看到了一些从等待context抛出的异常.CheckpointAsync();当reason == CloseReason.Shutdown时调用。

如何在本地调试中模拟这种情况?

1 个答案:

答案 0 :(得分:1)

当EventProcessorHost正在运行时 - 调用eventProcessorHost.UnregisterEventProcessorAsync() - 这将确保IEventProcessor.close()调用CloseReason.Shutdown

请参阅this to understand EPH concepts