public RabbitMqSubscriber(IRabbitConnectionWrapper connectionWrapper, ILogger logger, IServiceScopeFactory serviceScopeFactory) { _connection = connectionWrapper.Connection; _logger = logger; _channel = _connection.CreateModel(); _serviceScopeFactory = serviceScopeFactory; }
//TODO logging, stoppingTokens and dynamic exchangeTypes public Subscriber(Type consumerType, IServiceProvider serviceProvider) { _consumerType = consumerType; _serviceProvider = serviceProvider; _connection = serviceProvider.GetRequiredService <IRabbitConnectionWrapper>(); var attribute = consumerType.GetCustomAttribute <MessageHandlerAttribute>(); if (null == attribute) { throw new Exception("MessageHandler attribute not found, bad code implementation in assembly scanner library"); } _exchange = attribute.Exchange; _routingKey = attribute.RoutingKey; _needRequeue = attribute.RequeueOnFail; _queueName = $"{_exchange}.{_routingKey}->{consumerType.FullName}"; }
public RabbitMqProducer(IRabbitConnectionWrapper rabbitConnectionWrapper, RabbitMqConfig rabbitMqConfig) { _connection = rabbitConnectionWrapper.Connection; _rabbitMqConfig = rabbitMqConfig; }
public RabbitProducer(IRabbitConnectionWrapper rabbitConnectionWrapper) { _configuration = rabbitConnectionWrapper.Configuration; _channel = rabbitConnectionWrapper.Connection.CreateModel(); }