事件中心处理器 - 如何在本地开发箱中模拟 closereason.shutdown

Event Hub processor- How to simulate closereason.shutdown in local dev box

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

  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();
    }
}

而且我看到 await context.CheckpointAsync(); 抛出了一些异常;当 reason == CloseReason.Shutdown.

时调用

如何在本地调试模拟这个场景?

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

参见