Пример #1
0
 public RabbitMQSubscriber(
     ILogger <RabbitMQSubscriber> logger
     , SubscriberOptions subscriberOptions
     , PersistentConnection connection)
 {
     _logger           = logger;
     SubscriberOptions = subscriberOptions;
     QueueName         = subscriberOptions.QueueName;
     RouterKey         = subscriberOptions.RoutingKey;
     _connection       = connection;
 }
Пример #2
0
        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);
        }