public async Task StartAsync(CancellationToken cancellationToken) { var(cluster, session) = await BootStrapCassandra(_configuration.For <Configuration.Cassandra>(), _logger).ConfigureAwait(false); _session = session; _cluster = cluster; var rabbitMqConfiguration = _configuration.For <Configuration.RabbitMQ>(); _connection = BootStrapBroker(rabbitMqConfiguration); _consumer = await BootstrapConsumer(session, _connection, rabbitMqConfiguration).ConfigureAwait(false); _logger.Info("ServiceStarted"); }
private async Task <ConsumerOf <PurchaseOrder> > BootstrapConsumer(ISession session, IConnection connection, Configuration.RabbitMQ rabbitMqConfiguration) { var consumer = new ConsumerOf <PurchaseOrder>( new PurchaseOrderHandler(session, await session.PrepareAsync(PurchaseOrderHandler.InsertCql) .ConfigureAwait(false)), rabbitMqConfiguration, _cancellationTokenSource.Token, _logger); consumer.Start(connection); return(consumer); }