public BaseRabbitMqConsumer(IOptionsSnapshot <RabbitMqConfig> options , IHostApplicationLifetime appLifetime , ILogger <dynamic> logger) { _appLifetime = appLifetime; _connection = RabbitMqConnection.GetInstance(options, logger).Connection; _channel = _connection.CreateModel(); _logger = logger; }
public static RabbitMqConnection GetInstance(IOptionsSnapshot <RabbitMqConfig> options, ILogger <dynamic> logger) { if (_uniqueInstance == null || _uniqueInstance.Connection == null || _uniqueInstance.Connection.IsOpen == false) { lock (_lockObject) { if (_uniqueInstance == null || _uniqueInstance.Connection == null || _uniqueInstance.Connection.IsOpen == false) { _uniqueInstance = new RabbitMqConnection(options.Value, logger); } } } return(_uniqueInstance); }
public RabbitMqProducer(IOptionsSnapshot <RabbitMqConfig> options, ILogger <RabbitMqProducer> logger) { _logger = logger; _channel = RabbitMqConnection.GetInstance(options, logger).Connection.CreateModel(); }