private void InitRabbitMq()
        {
            var dbContext = _serviceScopeFactory.CreateScope();

            _rabbitDatabaseProvider = dbContext.ServiceProvider.GetRequiredService <IRabbitDatabaseProvider>();

            _responseRabbitService = dbContext.ServiceProvider.GetRequiredService <IResponseRabbitService>();

            _connection = _rabbitDatabaseProvider.BuildConnection(_configurations);

            _model = _connection.CreateModel();
        }
Пример #2
0
        public async Task <object> Post([FromServices] RabbitMqSettings configurations, [FromBody] Content content)
        {
            IConnection connection = _rabbitDatabaseProvider.BuildConnection(configurations);

            IModel model = connection.CreateModel();

            //Example Save Answer
            content.TypeOperation = ETypeOperation.Save;

            var sucess = await _responseRabbitService.PublishAsync(model, content);

            if (sucess)
            {
                return new { Resultado = "Published Message." }
            }
            ;

            return(new { Resultado = "Failed To Publish Message." });
        }
    }