Added new rabbitmq configs
This commit is contained in:
		@@ -17,14 +17,14 @@ namespace Birdmap.BLL.Services.CommunationServices.RabbitMq
 | 
			
		||||
        private IConnection _connection;
 | 
			
		||||
        private IModel _channel;
 | 
			
		||||
        private readonly IConnectionFactory _factory;
 | 
			
		||||
        private readonly string _topic;
 | 
			
		||||
        private readonly RabbitMqClientOptions _options;
 | 
			
		||||
 | 
			
		||||
        public override bool IsConnected => throw new NotImplementedException();
 | 
			
		||||
 | 
			
		||||
        public RabbitMqClientService(RabbitMqClientOptions options, ILogger<RabbitMqClientService> logger, IInputService inputService, IHubContext<DevicesHub, IDevicesHubClient> hubContext)
 | 
			
		||||
            : base(logger, inputService, hubContext)
 | 
			
		||||
        {
 | 
			
		||||
            _topic = options.Topic;
 | 
			
		||||
            _options = options;
 | 
			
		||||
            _factory = new ConnectionFactory()
 | 
			
		||||
            {
 | 
			
		||||
                HostName = options.Hostname,
 | 
			
		||||
@@ -85,17 +85,26 @@ namespace Birdmap.BLL.Services.CommunationServices.RabbitMq
 | 
			
		||||
            _connection = _factory.CreateConnection();
 | 
			
		||||
            _channel = _connection.CreateModel();
 | 
			
		||||
 | 
			
		||||
            _channel.ExchangeDeclare(exchange: "topic_logs", type: "topic");
 | 
			
		||||
            var queueName = _channel.QueueDeclare().QueueName;
 | 
			
		||||
            _channel.ExchangeDeclare(
 | 
			
		||||
                exchange: _options.ExchangeName,
 | 
			
		||||
                type: _options.ExchangeType,
 | 
			
		||||
                durable: _options.ExchangeDurable,
 | 
			
		||||
                autoDelete: _options.ExchangeAutoDelete);
 | 
			
		||||
 | 
			
		||||
            _channel.QueueBind(queue: queueName,
 | 
			
		||||
                                  exchange: "topic_logs",
 | 
			
		||||
                                  routingKey: _topic);
 | 
			
		||||
            _channel.QueueDeclare(
 | 
			
		||||
                queue: _options.QueueName,
 | 
			
		||||
                durable: _options.QueueDurable,
 | 
			
		||||
                exclusive: _options.QueueExclusive,
 | 
			
		||||
                autoDelete: _options.QueueAutoDelete);
 | 
			
		||||
 | 
			
		||||
            _channel.QueueBind(queue: _options.QueueName,
 | 
			
		||||
                                  exchange: _options.ExchangeName,
 | 
			
		||||
                                  routingKey: _options.Topic);
 | 
			
		||||
 | 
			
		||||
            var consumer = new AsyncEventingBasicConsumer(_channel);
 | 
			
		||||
            consumer.Received += OnRecieved;
 | 
			
		||||
 | 
			
		||||
            _channel.BasicConsume(queue: queueName,
 | 
			
		||||
            _channel.BasicConsume(queue: _options.QueueName,
 | 
			
		||||
                                 autoAck: true,
 | 
			
		||||
                                 consumer: consumer);
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
		Reference in New Issue
	
	Block a user