コード例 #1
0
ファイル: Service.cs プロジェクト: lsfera/dotnet_sample
        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");
        }
コード例 #2
0
ファイル: Service.cs プロジェクト: lsfera/dotnet_sample
        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);
        }