static void Main(string[] args) { var stopWatch = new Stopwatch(); stopWatch.Start(); // var adapter = new PollingEventStoreAdapter(new PassiveEventStore(), 50000, 5.Seconds(), 1000, () => DateTime.UtcNow, messageFunc => Console.WriteLine(messageFunc())); var adapter = new PollingEventStoreAdapter(new PassiveEventStore(), 50000, TimeSpan.FromSeconds(5), 1000, () => DateTime.UtcNow); int maxSubscribers = 50; for (int id = 0; id < maxSubscribers; id++) { int localId = id; adapter.Subscribe(0, new Subscriber { HandleTransactions = (transactions, info) => { Console.WriteLine( $"{stopWatch.Elapsed}: Subscriber {info.Id} received transactions {transactions.First().Checkpoint} to {transactions.Last().Checkpoint} on thead {Thread.CurrentThread.ManagedThreadId}"); Thread.Sleep(new Random().Next(100, 500)); return(Task.FromResult(0)); }, NoSuchCheckpoint = info => Task.FromResult(0) }, id.ToString()); Console.WriteLine($"{stopWatch.Elapsed}: Started subscriber {localId}"); Thread.Sleep(1000); } Console.WriteLine("Press a key to shutdown"); Console.ReadLine(); adapter.Dispose(); }
public void Dispose() { pollingAdapter?.Dispose(); }