private async Task Run(ISinkQueue <ImmutableList <Transaction> > queue) { while (!_isCancel.Value) { try { var data = await queue.PullAsync(); if (data.HasValue) { await _subscriber.HandleTransactions(data.Value, new SubscriptionInfo { Id = data.Value.Last().StreamId, Subscription = this }); } else { Thread.Sleep(1); } } catch (Exception e) { _errorHandler?.Invoke(_exceptionInfo, e); } } }
public async Task GlobalSetupAkkaAsync() { await SetupKafkaAsync(); await SetupAkkaAsync(); StartProducer(); var consumerSettings = ConsumerSettings <Null, string> .Create(ConsumerSystem, null, null) .WithBootstrapServers(Docker.KafkaAddress) .WithGroupId(KafkaGroup); var(control, queue) = KafkaConsumer.PlainSource(consumerSettings, Subscriptions.Topics(KafkaTopic)) .ToMaterialized( Sink.Queue <ConsumeResult <Null, string> >() .AddAttributes(new Attributes(new Attributes.InputBuffer(2000, 4000))), Keep.Both) .Run(ConsumerSystem.Materializer()); _kafkaControl = control; _sink = queue; }