public RabbitMQSubscriber( ILogger <RabbitMQSubscriber> logger , SubscriberOptions subscriberOptions , PersistentConnection connection) { _logger = logger; SubscriberOptions = subscriberOptions; QueueName = subscriberOptions.QueueName; RouterKey = subscriberOptions.RoutingKey; _connection = connection; }
public static SmartSqlDIBuilder AddRabbitMQSubscriber(this SmartSqlDIBuilder smartSqlDiBuilder, Action <SubscriberOptions> configure) { SubscriberOptions rabbitMqOptions = new SubscriberOptions(); configure?.Invoke(rabbitMqOptions); smartSqlDiBuilder.Services.AddSingleton <ISubscriber, RabbitMQSubscriber>(sp => { var loggerFactory = sp.GetRequiredService <ILoggerFactory>(); return(new RabbitMQSubscriber(loggerFactory.CreateLogger <RabbitMQSubscriber>() , rabbitMqOptions , new PersistentConnection(rabbitMqOptions, loggerFactory.CreateLogger <PersistentConnection>() ))); }); return(smartSqlDiBuilder); }