public ServerToUserMQClient(IRabbitMQContext rabbitMQContext, IOptions <ServerMessagesQueueConfiguration> options)
 {
     _queueConfiguration = options.Value;
     _model = rabbitMQContext.Connection.CreateModel();
     _model.ExchangeDeclare(_queueConfiguration.ExchangeName, _queueConfiguration.ExchangeType, _queueConfiguration.Durable, autoDelete: false);
     _model.QueueDeclare(_queueConfiguration.QueueName, _queueConfiguration.Durable, _queueConfiguration.Exclusive, _queueConfiguration.AutoDelete);
     _model.QueueBind(_queueConfiguration.QueueName, _queueConfiguration.ExchangeName, _queueConfiguration.RoutingKey);
 }
Example #2
0
 public MessageConsumerFromServerBackgroundService(ILogger <MessageConsumerFromServerBackgroundService> logger,
                                                   IServerToUserMQClient rabbitMQClient,
                                                   IOptions <ServerMessagesQueueConfiguration> queueOpt,
                                                   ITelegramService telegramService,
                                                   IOptions <TelegramBotConfiguration> telegramOpt)
 {
     _logger             = logger;
     _model              = rabbitMQClient.Model;
     _queueConfiguration = queueOpt.Value;
     _telegramService    = telegramService;
     botClient           = new TelegramBotClient(telegramOpt.Value.Token);
 }