public void ConfigureServices(IServiceCollection services)
        {
            var rabbitMQConfigurations = new RabbitMQConfigurations();

            new ConfigureFromConfigurationOptions <RabbitMQConfigurations>(
                Configuration.GetSection("RabbitMQConfigurations"))
            .Configure(rabbitMQConfigurations);
            services.AddSingleton(rabbitMQConfigurations);

            services.AddControllers();
        }
Beispiel #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddControllers();
            // Para este exemplo foi criado um container Docker baseado
            // em uma imagem do RabbitMQ. Segue o comando para geração
            // desta estrutura:
            // docker run -d --hostname rabbit-local --name testes-rabbitmq -p 5672:5672 -p 15672:15672 -e RABBITMQ_DEFAULT_USER=guest -e RABBITMQ_DEFAULT_PASS=guest rabbitmq:3-management
            var rabbitMQConfigurations = new RabbitMQConfigurations();

            new ConfigureFromConfigurationOptions <RabbitMQConfigurations>(
                Configuration.GetSection("RabbitMQConfigurations"))
            .Configure(rabbitMQConfigurations);
            services.AddSingleton(rabbitMQConfigurations);
        }
        public void ConfigureServices(IServiceCollection services)
        {
            var rabbitMQConfigurations = new RabbitMQConfigurations();

            new ConfigureFromConfigurationOptions <RabbitMQConfigurations>(
                Configuration.GetSection("RabbitMQConfigurations"))
            .Configure(rabbitMQConfigurations);
            services.AddSingleton(rabbitMQConfigurations);

            // Verificando a disponibilidade do broker de mensageria
            // através de Health Checks
            services.AddHealthChecks()
            .AddRabbitMQ(Configuration.GetConnectionString("RabbitMQ"), name: "rabbitMQ");
            services.AddHealthChecksUI();

            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
        }