これは、ここから取得した IEventProcessor 実装の一部です。
public class SimpleEventProcessor : IEventProcessor
{
public async Task ProcessEventsAsync(PartitionContext context, IEnumerable<EventData> events)
{
foreach (EventData eventData in events)
{
}
}
}
新しいイベントが EventHub に追加されると、ProcessEventsAsync メソッドが呼び出され、foreach ループを使用してイベントを処理できます。ここで説明した ObserverRegistry などを使用して、Observers を SimpleEventProcessor に追加したいと思います。提案された ObserverRegistry は次のようになります。
public class ObserverRegistry : IObserverRegistry<IProjectionWriterFactory>
{
IEnumerable<object> GetObservers(IProjectionWriterFactory factory)
{
yield return new LoanApplicationObserver();
yield return new OfferObserver();
// more observers...
}
}
残念ながら、欠けているものがいくつかあります。複数のオブザーバーを SimpleEventProcessor に登録して、イベントが ProcessEventsAsync からすべてのオブザーバーに渡され、最終的にその When メソッドに渡されるようにするにはどうすればよいですか?