示例#1
0
        public Task StartAsync(CancellationToken cancellationToken)
        {
            this.logger.LogInformation("Creating RabbitMQ connection.");

            var factory = RabbitConnectionFactory();

            this.connection = factory.CreateConnection(CreateConnectionId());
            var model = this.connection.CreateModel();

            this.declarationService.DeclareAll(model);

            // Find all controllers and wire them up
            foreach (var consumerMethod in Reflections.GetControllerConsumerMethods())
            {
                this.consumers.Add(
                    new RabbitConsumer(
                        consumerMethod,
                        model,
                        this.configuration,
                        this.serviceProvider,
                        this.loggerFactory.CreateLogger <RabbitConsumer>()));
            }

            return(Task.CompletedTask);
        }