public async Task StartAsync() { var exchanges = await _rabbitService.GetAllExchangesAsync(); var list = new List <RabbitMqSubscriber <string> >(); exchanges = exchanges.Where(x => Regex.IsMatch(x.Name, _rabbitMqSettings.ExchangeRegex)).ToList(); foreach (var exchange in exchanges) { var settings = RabbitMqSubscriptionSettings .ForSubscriber(_rabbitMqSettings.ConnectionString, exchange.Name, "rabbiteventstoragejob") .MakeDurable(); var func = new Func <string, Task>(x => _rabbitService.SaveMessageAsync( new RabbitMessage { ExchangeName = exchange.Name, Payload = x })); var subscriber = new RabbitMqSubscriber <string>( _logFactory, settings, new ResilientErrorHandlingStrategy( _logFactory, settings, TimeSpan.FromSeconds(10), next: new DeadQueueErrorHandlingStrategy(_logFactory, settings))) .SetMessageDeserializer(new JsonMessageDeserializer <string>()) .Subscribe(func) .CreateDefaultBinding() .Start(); list.Add(subscriber); } //await _rabbitService.RemoveSubscriptionsAsync(); }