// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { var rabbitMQConfigurations = new RabbitMQConfigurations(); new ConfigureFromConfigurationOptions <RabbitMQConfigurations>(Configuration.GetSection("RabbitMQConfigurations")).Configure(rabbitMQConfigurations); services.AddSingleton(rabbitMQConfigurations); services.AddControllers(); }
// This method gets called by the runtime. Use this method to add services to the container. // For more information on how to configure your application, visit https://go.microsoft.com/fwlink/?LinkID=398940 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=testes -e RABBITMQ_DEFAULT_PASS=Testes2018! rabbitmq:3-management var rabbitMQConfigurations = new RabbitMQConfigurations(); new ConfigureFromConfigurationOptions <RabbitMQConfigurations>( Configuration.GetSection("RabbitMQConfigurations")) .Configure(rabbitMQConfigurations); services.AddSingleton(rabbitMQConfigurations); services.AddHostedService <ConsumeRabbitMQHostedService>(); }